# How does the Json parser works in telegraf

**URL:** <https://community.influxdata.com/t/how-does-the-json-parser-works-in-telegraf/9052>\
**Category:** Telegraf\
**Tags:** telegraf\
**Created:** [March 18, 2019, 12:00pm UTC](https://community.influxdata.com/t/how-does-the-json-parser-works-in-telegraf/9052 "2019-03-18T12:00:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brottus](https://avatars.discourse-cdn.com/v4/letter/b/5e9695/32.png) [@Brottus](https://community.influxdata.com/u/Brottus)\
**Post date:** [March 18, 2019, 12:00pm UTC](https://community.influxdata.com/t/how-does-the-json-parser-works-in-telegraf/9052/1 "2019-03-18T12:00:13Z")

</div>

Hello Community,

i was trying to get out some data from a db with telegraf. Unfortunately the [https://github.com/influxdata/telegraf/pull/2785](https://github.com/influxdata/telegraf/pull/2785) will take some more time or never come to life who knows. Nevertheless i tried than to use the Inputs.exec plugin with my python wrapper script for the SQL queries which produces a JSON for telegraf. So Far so good but for any strange reason only the first Key-value-pair gets processed by telegraf. So i created a test.json out of my python script and used the Inputs.file plugin.  
So in my case i use the following test.json  
**{“test\_integer”: 78698, “test\_string1”: “test”, “test\_string2”: “Test-testo-testi”}**  
And it parsed to the following InfluxDB Line Protocol:  
**file,host=testserver test\_integer=78698 1552909841000000000**  
Should the expected behavior not be according to the doku to parse the JSON not in the following  
**file,host=testserver test\_integer=78698,test\_string1=“test”,test\_string2=“Test-testo-testi” 1552909841000000000**  
Please can someone verify or give me a hint why this is the behavior. I mean if my best bet is to create directly a InfluxDB Line Protocol or do i just misunderstood how the Parser works ?  
Thanks for the help.

---

<div class="post-metadata">

**Author:** ![Esity](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/esity/32/5864_2.png) [@Esity](https://community.influxdata.com/u/Esity)\
**Post date:** [March 18, 2019, 2:10pm UTC](https://community.influxdata.com/t/how-does-the-json-parser-works-in-telegraf/9052/2 "2019-03-18T14:10:01Z")

</div>

Are you specifically trying to store strings? The default JSON processors will avoid that and only store floats/integers

---

<div class="post-metadata">

**Author:** ![Brottus](https://avatars.discourse-cdn.com/v4/letter/b/5e9695/32.png) [@Brottus](https://community.influxdata.com/u/Brottus)\
**Post date:** [March 22, 2019, 12:39pm UTC](https://community.influxdata.com/t/how-does-the-json-parser-works-in-telegraf/9052/3 "2019-03-22T12:39:17Z")

</div>

Hi Esity,

thanks for the hint. I reread the docu again and understand my error. After playing around with the additional json parameters in the telegraf config i got it working as intended. The only question from me left is does the json parser sort the input directly as intended in the docs? I think he does cause it doesn’t matter how the json values were arranged it always were produced the same Influxdb line protocol line.

Thanks for the help.
