Let's follow up this discussion at the Neptune Community
(this forum will be kept in read-only mode)
Me again. :)
I have a generic data-structure that contains a field which holds dynamic data in JSON format. When I write this data to a Model, it is handled correctly. But when I use this model do an Ajax call, the internal field value within SAP does not contain the full JSON I've put into the field. It seems your JSON-parser has trouble finding another JSON within the JSON.
Do you have any solution for this?
My background is: I'm developing a generic app, that show a list where the user selects an entry. The entry holds generic info about it's detail in his body. This should be transferred to another (dynamically) embedded application, which handles those details and shows them. I seemed logical to me to use JSON for myself to keep the transferred data small. But it seems it collides with your parser.
I found out that my JSON makes a correct roundtrip back to the SAP-System. It's the internal filling of the model for the App-class that does not work.
There might be other ways for me to do this, so you don't need to change everything. :) But maybe there is a quick solution - replace special characters (masking) in my JSON or something like this.
Yes, of course. You can generate JSON dinamically from the ABAP class and get it in the browser.
Please check out the examples in Neptune Explored. Here you have one for VizFrame charting: https://template.neptune-software.com/neptune/sdk/explored.html#appEXP_SAMPLE_VIZ
Hi! Is possible to do something similar in backend and the parse it in browser? I need to generate dynamic json data for VizChart?
Hi Ole Andre,
thank you for your feedback. I'll check your code once the SP01 is out and will adjust my code accordingly. Thanks for staying on track with feedback you get!
Unfortunately I'm on another customers event I have booked already months before. So I'm not free on June 16th. I would have been very happy to meet developers, customers and partners on the event! Maybe next time!
Thank you for the great information and your technical skillset.
For neptune UX Platform 4.0 SP01 we have changed the inbound JSON parser. It should now be possible to paste an entire JSON stream into an input field and all parsed ok.
Will you attend Neptune UX Summit 2016 on the 16 June ?
I finally found the issue. As we have a non-Unicode system I've implemented the fix which is to uncomment the function call to SCP_TRANSLATE_CHARS within the method /NEPTUNE/CL_NAD_SERVER=>SERVER_DECODE_JSON. But unfortunately that function used the same variable for the inbuff and outbuff-parameters. When that field is too long the function throws an "overlapping buffer"-error. So I changed the coding in the way that I write the inbuffer ("data") to a local variable lv_data of type string and give that to the inbuff-parameter.
I also had to base64-encode my own JSON via cl_http_utility=>/if_http_utility~encode_base64. That helped to get my own JSON to do the roundtrip back to my ABAP.
So in short:
- Neptune-Users should encode own JSON within a STRING-field with cl_http_utility=>/if_http_utility~encode_base64
- You should change the code in SERVER_DECODE_JSON to write the data to a local variable before giving it to SCP_TRANSLATE_CHARS
Hinting me to encodeURIComponent triggered me in the right direction of BASE64-Encoding.
If you have the JSON string inside a structure/table in a field of type STRING, you can try to encode the content before putting it into the model. Use encodeURIComponent. Then you need to decode it in your application class.
Will that work ?