I am fetching data from reddit public api and receiving data in this format :
JSON recieved from Reddit’s public API with escape characters.
When I do it with simdjson, it throws me the following error:
terminate called after throwing an instance of ‘simdjson::simdjson_error’
what(): TAPE_ERROR: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc.
This happens, as far as i understand due to escape sequences present like “kind” : “Listing”… When I pass the json which get through nlohmann’s to simdjson which does not include escape sequences, simdjson parses it fine.
Does simdjson provide any solution for it? If some more info or reference is required, I will share.
Here is the code I am using for simdjson file: Simdjson Parse Code.
Thank you.
I tried Nlohmann’s lib and Qt’s json classes which parsed the data with escape sequences fine but simdjson is giving me many error, tried padded_string, padded_string_view and some other solutions I found and through gpt but none of them worked.
I am expecting a similar response to what nlohmann’s lib provided which is this:
{"data":{"after":null,"before":null,"children":[{"data":{"all_awardings":[],"approved_at_utc":null,"approved_by":null,"archived":false,"associated_award":null,"author":"CorvoLP","author_flair_background_color":null,"author_flair_css_class":null,"author_flair_richtext":[],"author_flair_template_id":null,"author_flair_text":null,"author_flair_text_color":null,"author_flair_type":"text","author_fullname":"t2_miadr","author_is_blocked":false,"author_patreon_flair":false, ... more same code
without escape sequence, or if it cant be provided, any way to read the json data with escape sequence in simdjson.
Sanjam Kapoor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.