# JSON parser for Spark

**URL:** <https://community.particle.io/t/json-parser-for-spark/2838>\
**Category:** Libraries\
**Created:** [February 14, 2014, 3:42am UTC](https://community.particle.io/t/json-parser-for-spark/2838 "2014-02-14T03:42:13Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [February 14, 2014, 3:42am UTC](https://community.particle.io/t/json-parser-for-spark/2838/1 "2014-02-14T03:42:14Z")

</div>

I ported a JSON parser called [**JSMN**](https://bitbucket.org/zserge/jsmn/wiki/Home) pointed out by Bdub. It is small and fast. If anyone is interested, I put the [**library and test code**](https://github.com/pkourany/JSMNSpark) on my github.

😄

---

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dave/32/181_2.png) [@Dave](https://community.particle.io/u/Dave)\
**Post date:** [February 14, 2014, 6:19pm UTC](https://community.particle.io/t/json-parser-for-spark/2838/2 "2014-02-14T18:19:44Z")

</div>

What? Yay! That’s sweet!

---

<div class="post-metadata">

**Author:** ![BDub](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bdub/32/5137_2.png) [@BDub](https://community.particle.io/u/BDub)\
**Post date:** [February 14, 2014, 6:37pm UTC](https://community.particle.io/t/json-parser-for-spark/2838/3 "2014-02-14T18:37:27Z")

</div>

VERY NICE @peekay123! Can’t wait to throw some big chunks of data at it and see what comes out.

---

<div class="post-metadata">

**Author:** ![a3electroniks](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/a3electroniks/32/708_2.png) [@a3electroniks](https://community.particle.io/u/a3electroniks)\
**Post date:** [February 20, 2014, 10:08pm UTC](https://community.particle.io/t/json-parser-for-spark/2838/4 "2014-02-20T22:08:13Z")

</div>

thanks @peekay123 just what i needed!

---

<div class="post-metadata">

**Author:** ![RWB](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rwb/32/22599_2.png) [@RWB](https://community.particle.io/u/RWB)\
**Post date:** [February 25, 2014, 1:20am UTC](https://community.particle.io/t/json-parser-for-spark/2838/5 "2014-02-25T01:20:12Z")

</div>

@peekay123 Yo!

I think I might be in the right place for something I’m trying to accomplish, you can let me know.

I have the Spark Core and the SHT-15 temp & humidity sensor up and running with the data being pushed to the spark cloud and then pulled into my Google Drive Spreadsheet via a script so I can log + graph out the temp data over time.

Now I have been using this for awhile now and it works great but now I want to also have the outside temp and humidity data on the same graph also so I can see the difference between inside and outside temp differences.

What do you think is the easiest way to get my local temp and humidity data pushed into my Google Drive Spreadsheet so I can graph it along with temp and humidity inside?

Is the simple JSON parser able to do this job? How could it work in plain english for this beginner over here 😄

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [February 25, 2014, 1:41am UTC](https://community.particle.io/t/json-parser-for-spark/2838/6 "2014-02-25T01:41:31Z")

</div>

RWB, it would seem to me you should be **pulling** it directly from you google script and not through your core. I did a quick google of “pull local weather data into google speadsheet” and found this [openWeatherMap free item](http://openweathermap.org/API#weather). You could pull your data using JSON and parse it just like you get the data from the core. 😄

---

<div class="post-metadata">

**Author:** ![harrisonhjones](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/harrisonhjones/32/4132_2.png) [@harrisonhjones](https://community.particle.io/u/harrisonhjones)\
**Post date:** [March 21, 2014, 3:13am UTC](https://community.particle.io/t/json-parser-for-spark/2838/7 "2014-03-21T03:13:07Z")

</div>

I get the following errors: [http://pastebin.com/MYRAh2ye](http://pastebin.com/MYRAh2ye)

It looks like NULL and size\_t are not defined. I’ve tried searching around it and looks like they SHOULD be defined but perhaps I’m doing something wrong?

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [March 21, 2014, 3:22am UTC](https://community.particle.io/t/json-parser-for-spark/2838/8 "2014-03-21T03:22:14Z")

</div>

harrisonhjones, you need to add #include “application.h” in the jsmnSpark.h file. I posted that before that became a requirement!

---

<div class="post-metadata">

**Author:** ![fangda01](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/fangda01/32/4946_2.png) [@fangda01](https://community.particle.io/u/fangda01)\
**Post date:** [August 6, 2015, 4:04pm UTC](https://community.particle.io/t/json-parser-for-spark/2838/9 "2015-08-06T16:04:17Z")

</div>

Sorry i test JSMN

and change jsmndemo.cpp  
js = “{“token”:123456789,“barcode”:[123456789,“barcode01”],“quantity”:[1,5]}”;

and resulte = parse failed

how syntax is work ?

i test API me  
request  
token: 123456789,  
barcode: [‘barcode3’, ‘barcode3’],  
quantity: [1, 1] }

response  
[{“info”:{“api”:“Summit API Beep to buy”,“customerid”:“0000000000”,“name”:{“firstname”:“admin”,“lastname”:“admin”},“total”:60,“token”:123456789,“detail”:[{“prodname”:“barcode3”,“unitprice”:30},{“prodname”:“barcode3”,“unitprice”:30}]}}]

i want to parse to array obj  
prodname[] , unitprice[] ,

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [August 6, 2015, 4:16pm UTC](https://community.particle.io/t/json-parser-for-spark/2838/10 "2015-08-06T16:16:02Z")

</div>

@fangda01, you can get the documentation for the orignal code here:

[https://bitbucket.org/zserge/jsmn/wiki/Home](https://bitbucket.org/zserge/jsmn/wiki/Home)
