Cannot use 'in' operator to search for '$ref' in 0
-
I keep getting the exception Cannot use 'in' operator to search for '$ref' in 0 from Jsreport while using "RenderbyNameAsync" method in the jsreport.client. What i don't seem to understand is the fact that the same template renders if i make a restful call to the endpoint without any problem. I thought the timeout could be a problem and tried using RenderAsync Method with the Renderrequest Overload method. Again it ends up in the same error. I couldn't figure out why. For now i have hardwired the http call in my App. I also tried cloning the jsreport client library and added that to my project to debug this error around. But ending up in BadRequest Response Code and with the same exception with no further clues around. Do someone see what could be going on here.. Here's the full Exception from jsreport studio
Cannot use 'in' operator to search for '$ref' in 0
TypeError: Cannot use 'in' operator to search for '$ref' in 0 at recurse (/app/node_modules/jsreport-core/lib/render/resolveReferences.js:19:20) at recurse (/app/node_modules/jsreport-core/lib/render/resolveReferences.js:44:22) at recurse (/app/node_modules/jsreport-core/lib/render/resolveReferences.js:22:20) at recurse (/app/node_modules/jsreport-core/lib/render/resolveReferences.js:44:22) at module.exports (/app/node_modules/jsreport-core/lib/render/resolveReferences.js:52:5) at module.exports (/app/node_modules/jsreport-core/lib/render/engineScript.js:29:17) at IncomingMessage. (/app/node_modules/script-manager/lib/worker-servers.js:239:47) at emitNone (events.js:106:13) at IncomingMessage.emit (events.js:208:7) at endReadableNT (_stream_readable.js:1064:12)+0 Starting rendering request 1740 (user: admin)
+7 Rendering template { name: DSMCompanyReports, recipe: chrome-pdf, engine: handlebars, preview: false }
+8 Inline data specified.
+8 Resources not defined for this template.
+11 Replaced assets ["dsmcompanyreport.css","Akkurat-Normal.ttf","Akkurat-Bold.ttf","lineto-akkurat-pro-light.woff"]
+11 Base url not specified, skipping its injection.
+11 Rendering engine handlebars
-
The jsreport.client uses json.net feature to preserve references.
https://www.newtonsoft.com/json/help/html/PreserveReferencesHandlingObject.htm
https://github.com/jsreport/jsreport-dotnet-shared/blob/master/jsreport.Shared/SerializerHelper.cs#L113It seems that it somehow creates invalid format of such json in the end.
Would you be able to send me the data you are passing into the rendering request?
-
Hello Jan, Thanks for your reply. I captured the output of ValidateandSerialize Request in jsclient and attached here. See if you find something off about this https://drive.google.com/open?id=1Op9BJJ6WbXVTGiKOjym5pukVrk8MOrSe
-
Hello Jan, you were spot on about the PreserveReferencesHandling.Objects. I disabled it in the client library during debug and everything went well. But what seems odd thought is the fact that the JSON is well formed in both cases ( before and after Enabling Preservereferences Settings ) but the rendering works only if the PreserveReferences Settings is turned off... I have attached the Json after turning off PreserveReferences.... I don;t see what's doing the trick here https://drive.google.com/open?id=1DVxU5RrDT-lId7sg0jERs298GvPOVkuN
-
Thank you for sharing the json. It helped me to track the problem. It sits in the jsreport core deserializer.
Please use workaround that manually serializes the data field in .net
var manuallySerializedData = JsonConvert.SerializeObject(new { a = new int[3] { 1, 2, 3 } }); var report = rs.RenderByNameAsync("a", manuallySerializedData).Result;
We will make sure to fix this in jsreport during the next release.
-
Wow, You are so Cool :) Thanks a ton again !!