Two dimenstional array not working inside <script> tag
When passing the two-dimensional array is not working inside <script> tag and it is automatically converted to a string.
Orginal Data from API : [[1656558660000,1082],[1656558720000,16000],[1656558780000,53311],[1656558840000,112095],[1656558900000,193935]]
Actual Result getting when passing the data inside script tag: 1656558660000,1082,1656558720000,16000,1656558780000,53311,1656558840000,112095,1656558900000,193935
Expected result : two-dimensional array as it is Orginal Data from API
There shouldn't be some flattening happening.
Could you please provide a minimal playground replicating the problem?
I am also experiencing the same thing.
Check my sample report: https://playground.jsreport.net/w/aquater08/2Dtg2~r9
Replace the binding with the same value from the data template to see the difference.
Background: The value of the every element should be [y, x]. However, when binding the data, the array becomes a single array [y].
Is there a workaround for this?
The problem is described in this older but still valid post
jsrender/handlebars isn't doing JSON serialization when you do this
but it's own "to text" serialization so you end with this
The solution mentioned in the post works well, but jsreport has since v3 already system helper for you.
Hint: I like to use
textrecipe for troubleshooting to see whats exactly is printed by handlebars before being evaluated by chrome.
jan_blaha. ~toJS worked! Thank you!