JsonRenderingExtension creates invalid JSON

Posted by: jharrell on 10 January 2020, 4:53 am EST

  • Posted 10 January 2020, 4:53 am EST

    We are you the JsonRenderingExtension in AR12 but the issue seems to be in 13 and 14.

    The JSON output is not escaped correctly so if a string value contains a double quote or slash it creates invalid JSON that cannot be parsed.

    Looking at the source code through a decompiler it seems you are not using a JSON library to create the JSON and instead are simply concatenating strings leading to this issue.

    Another less critical issue is that you are ignoring DataElementName. You do seem to be honoring DataElementOutput which allowed us to bypass the escaping issue by setting NoOutput to certain textboxes that could have quotes or slashes in them for now.

    Attached is a report the demonstrates the problem if exported to JSON

    Invalid JSON test.zip

  • Posted 12 January 2020, 9:43 pm EST

    Hello,

    “DataElementName” property is used to set the property name for value of the textbox. Suppose if you have textbox value ‘test’ and “DataElementName” set to “Name” then Json will be generated as follow:

    {

    Name: “Test”

    }

    Whereas, “DataElementOutput” allows you to control whether the specific report item will be present in the export or not.

    Regarding quote issue, I am able to replicate the issue at my end. However, I am observing the same issue with V12. Request to please share the exact version of AR12 that you are using in which quote issue does not occur.

    Thanks,

    Mohit

  • Posted 13 January 2020, 7:47 am EST

    So running further test, DataElementName is not being honored in AR13 but does seem to work in AR12, not sure about AR14. However the default export does not use quoted names and will also break the JSON with DataElementName that have spaces.

    I think its a mistake to offer JSON export with the option to not quote keys, even worse to have it default to that. It is not valid JSON to have unquoted keys even though its valid in javascript.

    Maybe I should have made it more clear on the value quote issue, it is happening in AR12 for us as well and AR13.

  • Posted 14 January 2020, 2:08 am EST

    Yes I noticed QuotePropertyName however it defaults to unquoted, which is invalid JSON. I am not sure why you even have this option, but if its there it should default to creating valid JSON.

    Also with it off you should detect DataElementNames with spaces and quote them anyway otherwise the JSON is broken will not parse even in less strict parsers that allow unquoted names.

    I would prefer a fix in both AR14 and AR13 we don’t yet have a timeline for upgrading to AR14 but are preparing AR13 rollout and will be moving to AR14 sometime this year.

  • Posted 15 January 2020, 10:36 pm EST

    Hello,

    About “DataElementName”, I am able to observe the difference in both AR13 and AR14 and escalated the same to our development team(278151).

    Also, there is property “QuotePropertyName” to add the quote on the key. Please set it “True” to achieve the desired behavior.

    Maybe I should have made it more clear on the value quote issue, it is happening in AR12 for us as well and AR13.

    I just want to confirm the behavior at your end before escalating this to our developers. I have forwarded this to our development team (278150)and will inform you once I got any reply from them

    Request to please confirm do you want this fix in AR14 or AR13 or both?

    Thanks,

    Mohit

  • Posted 15 January 2020, 10:37 pm EST

    Hello,

    I have forwarded the enhancement(278152) to set QuotePropertyName property to “true” by default.

    If you have any more questions regarding this, please let me know.

    Thanks,

    Mohit

  • Posted 5 February 2020, 12:22 am EST

    Hello,

    Maybe I should have made it more clear on the value quote issue, it is happening in AR12 for us as well and AR13.

    The issue gets fixed in the latest hotfix of AR13. Please download the same from the following link:

    http://cdn.grapecity.com/ActiveReports/AR13/hotfixes/ActiveReports-v13.2.18731.0.msi

    Thanks,

    Mohit

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels