× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Suren,

Why not always define the array with a 9999 size?  That seems much simpler and more robust.  What are you gaining by declaring it to a pointer and only allocating part of it?

If you did want to do it with a dynamic allocation, you could do it by calling YAJL's subprocedures to parse the document (i.e. don't use DATA-INTO, just call YAJL's routines).   This could give you the size, and then you could parse it a second time with DATA-INTO after you knew the size and have allocated the data. But this would be more complicated, and parsing it twice (no matter how you do it) will take longer than parsing it once.  So, I would simply always declare the array with the full 9999, I would not bother with the dynamic allocation.

-SK


On 6/19/2019 2:36 PM, Suren K wrote:
Hi Everyone,

I am using Scott's YAJL Parser using DATA-INTO opcode for Parsing the JSON
Document. I need one clarification.

Currently i am using the JSON Document which contains an array which we
cannot limit the number of elements. So i need to define an array data
structure with minimum 9999 elements by assuming the number of elements
will not exceeds 9999.

Instead of doing this, i am planning to use pointer based array data
structure. Once i identified the number of elements by using the option
"Countprefix", i can allocate the data structure based on the number of
elements and then use the data structure in DATA-INTO to parse the full
data.

But i could see the "countprefix" option is working only when we pass the
array Data structure together with the countprefix variable in the
DATA-INTO Opcode.

Any suggestions to how to identify the number of elements first before
parsing the Entire Array?

Regards,
Surender K
+1 7022091188

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.