<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>event driven parser &#8211; Squix &#8211; TechBlog</title>
	<atom:link href="https://blog.squix.org/tag/event-driven-parser/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.squix.org</link>
	<description></description>
	<lastBuildDate>Sun, 17 Apr 2016 07:56:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.8</generator>
<site xmlns="com-wordpress:feed-additions:1">121913304</site>	<item>
		<title>ESP8266/Arduino: processing huge JSON objects directly on the ESP</title>
		<link>https://blog.squix.org/2015/10/esp8266arduino-processing-huge-json.html</link>
					<comments>https://blog.squix.org/2015/10/esp8266arduino-processing-huge-json.html#comments</comments>
		
		<dc:creator><![CDATA[Daniel Eichhorn]]></dc:creator>
		<pubDate>Sun, 25 Oct 2015 12:20:00 +0000</pubDate>
				<category><![CDATA[Common]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[ESP8266]]></category>
		<category><![CDATA[event driven parser]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[streaming parser]]></category>
		<guid isPermaLink="false">http://blog.squix.org/2015/10/25/esp8266arduino-processing-huge-json/</guid>

					<description><![CDATA[For a while now I wanted to improve my weather station project by adding more sources of information that can be displayed. But these sources I had in mind either used SSL (https) or delivered huge JSON responses. SSL is not yet supported on the ... <p><a class="read-more btn btn-secondary" href="https://blog.squix.org/2015/10/esp8266arduino-processing-huge-json.html">Read More</a></p>]]></description>
										<content:encoded><![CDATA[<div dir="ltr" style="text-align: left;" trbidi="on">
For a while now I wanted to improve my weather station project by adding more sources of information that can be displayed. But these sources I had in mind either used SSL (https) or delivered huge JSON responses. SSL is not yet supported on the ESP8266/Arduino platform (and from what I hear also broken on Nodemcu/Lua). Big JSON objects are a problem because all the existing libraries I tried are DOM based which consumes a lot of memory since they keep the whole JSON object in memory (at least once).</p>
<p>So I decided to tackle one problem at a time and looked at the big JSON object issue first. If you want to parse big documents you can either build a representation of the object in memory (DOM) or you can write a event based parser. This means that your parser is processing the document as it comes in as a stream, character by character and that it will notify you with different event types once portions of the document were parsed successfully. This is very helpful since you don&#8217;t have to keep the whole &nbsp;document in memory and you can even start parsing the stream almost immediately. You might be familiar with the SAX parser for XML which also follows this concept.</p>
<p>This concept is very useful on devices with little memory as the ESP8266. Looking for a start I found such a stream based <a href="https://github.com/squix78/jsonstreamingparser" target="_blank">JSON parser written in PHP</a> and decided to port it to C++.</p>
<p>The result looks very promising: I wrote a little example program for the ESP8266 which downloads a sample JSON object of 1MB size. In the sketch I&#8217;m only interested in one of the 5000 sub-objects and print it out as soon as I see it. During processing I print out the heap size with ESP.getFreeHeap() and the available heap size remains stable at around 32KB!</p>
<p>If you like to try it out you can find the library here:&nbsp;<a href="https://github.com/squix78/json-streaming-parser">https://github.com/squix78/json-streaming-parser</a>. In theory it should work for any Arduino target device but I only tested it with the ESP8266.</p>
<p>Happy hacking!</p></div>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.squix.org/2015/10/esp8266arduino-processing-huge-json.html/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">26</post-id>	</item>
	</channel>
</rss>
