2014-07-04 19:11:04 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								Arduino JSON library
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								====================
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-07-19 16:05:42 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*An elegant and efficient JSON library for embedded systems.*
							 
						 
					
						
							
								
									
										
										
										
											2014-07-04 19:11:04 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								It's design to be very lightweight, works without any allocation on the heap (no malloc).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-07-05 12:53:34 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								It has been written with Arduino in mind, but it isn't linked to Arduino libraries so you can use this library in any other C++ project.
							 
						 
					
						
							
								
									
										
										
										
											2014-07-04 19:11:04 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-07-05 16:09:37 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Features
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								--------
							 
						 
					
						
							
								
									
										
										
										
											2014-07-04 19:11:04 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								*  JSON decoding: [more details here ](/JsonParser/ )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								*  JSON encoding: [more details here ](/JsonGenerator/ )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								*  Elegant API, very easy to use 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								*  Fixed memory allocation (no malloc)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								*  Small footprint
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								*  MIT License
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-07-05 16:09:37 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Feature comparison
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								------------------
							 
						 
					
						
							
								
									
										
										
										
											2014-07-04 19:11:04 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-07-07 20:04:25 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								| Library      | Memory allocation | Nested objects | Parser size | Encoder size  |
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								| ------------ | ----------------- | -------------- | ----------- | ------------- |
							 
						 
					
						
							
								
									
										
										
										
											2014-07-19 16:05:42 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								| Arduino JSON | static            | yes            | 2642 Bytes  | 628 bytes     |
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								| json-arduino | dynamic           | no             | 3348 (+27%) | not supported |
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								| aJson        | dynamic           | yes            | 5088 (+93%) | 4678 (+640%)  |
							 
						 
					
						
							
								
									
										
										
										
											2014-07-04 19:11:04 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-07-09 19:48:55 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								"Parser size" was measured with a program parsing `{"sensor":"outdoor","value":25.6}` .
							 
						 
					
						
							
								
									
										
										
										
											2014-07-05 12:53:34 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								For each library, I wrote a program that extracts a string and a float. I subtracted the size of a program doing the same without any JSON parsing involved. [Source files are here ](https://gist.github.com/bblanchon/e8ba914a7109f3642c0f ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-07-09 19:48:55 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								"Encoder size" was measured with a program generating `{"sensor":"outdoor","value":25.6}` .
							 
						 
					
						
							
								
									
										
										
										
											2014-07-05 12:53:34 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[Source files are here ](https://gist.github.com/bblanchon/60224e9dcfeab4ddc7e9 ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								In each case the target platform was an Arduino Duemilanove and Arduino IDE 1.0.5 was used. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Links: [json-arduino ](https://github.com/not404/json-arduino ), [aJson ](https://github.com/interactive-matter/aJson ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-04 19:11:04 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-07-05 16:09:37 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Testimonials
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								------------
							 
						 
					
						
							
								
									
										
										
										
											2014-07-04 19:11:04 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								From Arduino's Forum user `jflaplante` :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								>  I tried the  [aJson and json-arduino] before trying your library. I always ran into memory problem after a while. 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								>  I have no such problem so far with your library. It is working perfectly with my web services.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								From Arduino's Forum user `gbathree` :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								>  Thanks so much - this is an awesome library!  If you want to see what we're doing with it - the project is located at www.photosynq.org.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								From StackOverflow user `thegreendroid` :
							 
						 
					
						
							
								
									
										
										
										
											2014-07-05 16:09:37 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								>  It has a really elegant, simple API and it works like a charm on embedded and Windows/Linux platforms. We recently started using this on an embedded project and I can vouch for its quality.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Links
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								-----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-07-19 16:05:42 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  [The project I originally wrote this library for ](http://blog.benoitblanchon.fr/rfid-payment-terminal/ )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								*  [Motivation for this library ](http://blog.benoitblanchon.fr/arduino-json-parser/ )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								*  [Release of version 2 ](http://blog.benoitblanchon.fr/arduino-json-v2-0/ )