Displaying JSON String in a Subfile using YAJL
Displaying JSON String in a Subfile using YAJL
I want to take nested data structures with data in them, create a formatted JSON string and then write the JSON string into a subfile for viewing. I went through the Working with JSON and RPG PDF. We use YAJL in our web services. After you do the last YAJL_ENDOBJ() is the data in a string somewhere and if it is how does YAJL know what string to place it in? If it's not in a string, how can I get it into a string that I can parse and load a subfile with? Thanks.
Re: Displaying JSON String in a Subfile using YAJL
If you have a nested data structure as the source of your JSON why not just use DATA-GEN with YAJLGEN rather than the YAQJL routines directly?
Re: Displaying JSON String in a Subfile using YAJL
I believe that DATA-GEN didn't come out until IBM i 7.3+ and we have to compile at IBM i 7.2 until all of our LPAR's have been converted to IBM i 7.4. So I will still like to know where the JSON data is placed once the last YAJL_ENDOBJ() is run so I can access it. Thanks.
-
- Site Admin
- Posts: 872
- Joined: Sun Jul 04, 2021 5:12 am
Re: Displaying JSON String in a Subfile using YAJL
Call yajl_copyBufStr() to copy the JSON data from YAJL into a string in your program.
If you need to handle more than 2mb, use yajl_copyBuf() instead. This does require working with pointers, so I would avoid it unless you can't use yajl_copyBufStr().
Code: Select all
myVariable = yajl_copyBufStr();
Re: Displaying JSON String in a Subfile using YAJL
Thank you Scott!