4 ms·
Can anyone state the JSON parsing problem more concisely. For example, 1. Here is the input, e.g., https://data.sfgov.org/api/views/acdm-wktn/rows.json?acces
by 1vuio0pswjnm7 4y ago
Can anyone state the JSON parsing problem more concisely. For example,
1. Here is the input, e.g., https://data.sfgov.org/api/views/acdm-wktn/rows.json?accessType=DOWNLOAD https://data.sfgov.org/api/views/acdm-wktn/rows.json?accessT...
2. Here is the desired output, e.g., a sample showing what the output is supposed to look like
- pclmulqdq 4y agoHaving written a few of them, the input is well-defined but the output is not. It generally depends on what you want to do with the JSON parser. If you are trying to get a generic key-value output, you can do that with a hash table, but you have to still access the keys by name. If you want to populate a struct, you should do something different for maximum speed (parse the fields directly).
- dahart 4y agoThere were several JSON problems mentioned in the article. One was parsing large arrays & floats. Another was DOM style parsing vs streaming. The point of using a streaming JSON parser is to avoid building an "output" per se, and instead handle the elements of the input as though they're events, concurrently with reading the input. In other words, turn parsing into an event handling system with many small events, rather than producing a single large data structure. One reason to do this is to avoid string allocation for every key and string value in the input, because that's where a huge chunk of the time goes when you use a non-streaming parser. Some people call this parsing style SAX parsing (https://en.wikipedia.org/wiki/Simple_API_for_XML https://en.wikipedia.org/wiki/Simple_API_for_XML) Here's an example https://rapidjson.org/md_doc_sax.html https://rapidjson.org/md_doc_sax.html
- 1vuio0pswjnm7 4y agoAnother way to state the question is, "If the input was in a format that required no JSON processing, nor other processing, what would that format look like?" For example, maybe it is a simple key,value table. I do not know. What makes it easier for me to understand is a sample of what that format looks like.