{"id":13591449,"url":"https://github.com/squix78/json-streaming-parser","last_synced_at":"2025-04-09T12:08:40.906Z","repository":{"id":59496257,"uuid":"44856715","full_name":"squix78/json-streaming-parser","owner":"squix78","description":"Arduino library for parsing potentially huge json streams on devices with scarce memory","archived":false,"fork":false,"pushed_at":"2022-12-13T01:16:25.000Z","size":18,"stargazers_count":212,"open_issues_count":21,"forks_count":89,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-02T11:06:38.599Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/squix78.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-24T07:29:44.000Z","updated_at":"2025-02-26T04:46:32.000Z","dependencies_parsed_at":"2023-01-28T04:00:33.205Z","dependency_job_id":null,"html_url":"https://github.com/squix78/json-streaming-parser","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squix78%2Fjson-streaming-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squix78%2Fjson-streaming-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squix78%2Fjson-streaming-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squix78%2Fjson-streaming-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/squix78","download_url":"https://codeload.github.com/squix78/json-streaming-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248036067,"owners_count":21037092,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T16:00:57.717Z","updated_at":"2025-04-09T12:08:40.886Z","avatar_url":"https://github.com/squix78.png","language":"C++","readme":"# json-streaming-parser\nArduino library for parsing potentially huge json streams on devices with scarce memory.\n\nThis library is a port of Salsify's PHP based json streaming parser (https://github.com/salsify/jsonstreamingparser).\n\n## Why yet another JSON parser?\n\nWhen working with small (connected) devices you might quickly get to the point where you need to process potentially huge JSON object received from a REST interface.\nAll libraries for processing JSON objects on the Arduino platform had some deficiencies which led me to create one on my own.\nNot really being an expert in writing parsers I miserably failed the first time. \n\nThis is the second attempt and I took Salsify's PHP based parser and ported it to C++. \nThis library has been tested on the Arduino/ESP8266 target platform but should work in theory on all platforms available for the Arduino environment\n\n## Why a streaming parser?\n\nGenerally speaking when parsing data you have two options to make sense of this data: \nyou either create a document object model (DOM) which contains the whole information of that document and lets you retrieve the\nnodes with random access. A DOM parser needs the whole document to start parsing and only lets you access the data\nafter it has finished the process.\nThe other option you have when parsing a document is to process it char by char (or byte by byte) while it becomes\navailable to your client code. Compared to the DOM parser this has two advantages: a) you can react\nthe data as soon as meaningful parts are available and b) you can drop information as soon as the parser has processed\nit. This reduces the memory consumption a lot, especially if you retrieve huge documents when only being interested\nby a small subset of it. But this efficiency comes at a price: your code will have to do more \"magic\" than with a\nDOM parser, the business logic becomes part of the parser.\n\n## How to install\n\nUntil the library becomes available in the Arduino IDE library manager you'll have to do a bit more work by hand.\n1) Download this library: https://github.com/squix78/json-streaming-parser/archive/master.zip\n2) Rename master.zip to json-streaming-parser.zip\n3) Open the zip file in the Arduino IDE from menu Sketch \u003e Include Library \u003e Add ZIP Library...\n\n## How to use\n\nThis is a streaming parser, which means that you feed a stream of chars into the parser and you take out from that\nstream whatever you are interested in. In order to do that you will create a subclass of JsonListener class and\nimplement methods which will be notified in case of certain events in the feed occure. Available events are:\n\n * startDocument()\n * key(String key)\n * value(String value)\n * endArray()\n * endObject()\n * endDocument()\n * startArray()\n * startObject()\n\nIn your implementation of these methods you will have to write problem specific code to find the parts of the document that you are interested in. Please see the example to understand what that means. In the example the ExampleListener implements the event methods declared in the JsonListener interface and prints to the serial console when they are called.\n\n## License\n\nThis code is available under the MIT license, which basically means that you can use, modify the distribute the code as long as you give credits to me (and Salsify) and add a reference back to this repository. Please read https://github.com/squix78/json-streaming-parser/blob/master/LICENSE for more detail...\n\n## Credits\n\nFirst of all I'd like to thank Salsify for making their PHP parser available to the public. You find their repository here: https://github.com/salsify/jsonstreamingparser\n\nThen I'd like to thank my employer Netcetera (https://github.com/netceteragroup) to let us hackers go twice a year to the CodeCamp and work on software projects like this one.\n\nAnd last but not least I'd like to thank my wife that she led me spend three days away from the family hacking in the wonderful mountains of Berne.\n","funding_links":[],"categories":["C++","Libraries"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquix78%2Fjson-streaming-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsquix78%2Fjson-streaming-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquix78%2Fjson-streaming-parser/lists"}