qb64pe-json - A library for JSON parsing and creation
#5
The JSON is an ordinary text file, right? So just create a subprogram that returns the starting and end lines of braces for the largest entry. Then nest this particular search, narrowing down to a wanted field.

Something like:
SearchField json$, field$, value$, instart, inend, outstart, outend

Then use the "outstart" and "outend" as the new input range for a different field which is the child of the previous value of "field$". Like in the example above, first call this subprogram with "shapes" as "field$" and "value$" set to null string, then call it with "name" as "field$", and "value$" to something expected as value of "name" field.

It could just be the first call to this imaginary subprogram and capture whatever value is associated with "name" field, building a string array out of it. The important thing is to limit which big "record" to search into.

It would take more work out of that to find out which other fields exist which are cohorts of the sought one, and then report on all of them. Report it in a sensible way too. Difficult, but not impossible. BASIC doesn't have regular expressions but the string functions are quite good, have been workhorses for almost four centuries so far.
Reply


Messages In This Thread
RE: qb64pe-json - A library for JSON parsing and creation - by mnrvovrfc - 03-23-2023, 12:47 AM



Users browsing this thread: 2 Guest(s)