# Webhooks JSON seems invalid

**URL:** <https://community.particle.io/t/webhooks-json-seems-invalid/20623>\
**Category:** Troubleshooting\
**Created:** [March 1, 2016, 4:03pm UTC](https://community.particle.io/t/webhooks-json-seems-invalid/20623 "2016-03-01T16:03:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cdasher](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/cdasher/32/9095_2.png) [@cdasher](https://community.particle.io/u/cdasher)\
**Post date:** [March 1, 2016, 4:03pm UTC](https://community.particle.io/t/webhooks-json-seems-invalid/20623/1 "2016-03-01T16:03:59Z")

</div>

Here is my webhook definition:

```auto
{
    "event": "checkin",
    "url": "http://myserveraddress/checkin",
    "requestType": "POST",
        "headers": {
        "Content-Type": "application/json"
        },

    "json": {
        "vbat" : "{{vbat}}",
        "soc" : "{{soc}}",
        "deviceid" : "{{SPARK_CORE_ID}}",
        "published" : "{{SPARK_PUBLISHED_AT}}",
        "event" : "{{SPARK_EVENT_NAME}}"
    },
    "noDefaults": true,
    "mydevices": true
}

```

In my firmware, i publish like this:

```auto
Particle.publish("checkin", "{\"vbat\":" + String(fuel.getVCell()) + ", \"soc\":" + String(fuel.getSoC()) +"}",60, PRIVATE);`

```

I am using nodejs and when it reaches my server, the req.body looks like this:

```auto
{ vbat: '3.945',
  soc: '87.78125',
  deviceid: 'mydeviceid',
  published: '2016-03-01T15:57:50.268Z',
  event: 'checkin' }

```

This does not parse and JSONLint says it is invalid (due to the lack of quotations). I am sure I ak just missing something. Any help is appreciated 😄

---

<div class="post-metadata">

**Author:** ![cdasher](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/cdasher/32/9095_2.png) [@cdasher](https://community.particle.io/u/cdasher)\
**Post date:** [March 1, 2016, 4:47pm UTC](https://community.particle.io/t/webhooks-json-seems-invalid/20623/2 "2016-03-01T16:47:20Z")

</div>

interstingly, when I publish the webhook, it gives me the incorrect json format in the message:

Sending webhook request { uri: ‘/v1/webhooks’,  
method: ‘POST’,  
json:  
{ event: ‘checkin’,  
url: ‘[http://myserver/checkin](http://myserver/checkin)’,  
deviceid: undefined,  
requestType: ‘POST’,  
mydevices: true,  
headers: { ‘Content-Type’: ‘application/json’ },  
json:  
{ vbat: ‘{{vbat}}’,  
soc: ‘{{soc}}’,  
deviceid: ‘{{SPARK\_CORE\_ID}}’,  
published: ‘{{SPARK\_PUBLISHED\_AT}}’ },  
noDefaults: true },  
headers: { Authorization: ‘Bearer xxxxxxx’ } }

---

<div class="post-metadata">

**Author:** ![rickkas7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rickkas7/32/8681_2.png) [@rickkas7](https://community.particle.io/u/rickkas7)\
**Post date:** [March 1, 2016, 4:59pm UTC](https://community.particle.io/t/webhooks-json-seems-invalid/20623/3 "2016-03-01T16:59:19Z")

</div>

I don’t have an answer to your actual problem, but as for the invalidity of the JSON: yes, it’s technically invalid. But every JSON parser should be able to handle it, because it’s a very commonly used variation.

Strictly following the spec, strings should be indicated by double quotes, not single quotes. And in an object definition, the key is a string, so therefore it should be double-quoted.

However, using single quotes is widely done. And eliminating the quotes on the keys in the object when the key consists only of alphanumeric characters is also widely done.

---

<div class="post-metadata">

**Author:** ![cdasher](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/cdasher/32/9095_2.png) [@cdasher](https://community.particle.io/u/cdasher)\
**Post date:** [March 1, 2016, 5:20pm UTC](https://community.particle.io/t/webhooks-json-seems-invalid/20623/4 "2016-03-01T17:20:52Z")

</div>

> [@cdasher](#):
>
> {  
> "event": "checkin",  
> "url": "[http://myserveraddress/checkin](http://myserveraddress/checkin)",  
> "requestType": "POST",  
> "headers": {  
> "Content-Type": "application/json"  
> },
> 
> ```
> "json": {
> "vbat" : "{{vbat}}",
> "soc" : "{{soc}}",
> "deviceid" : "{{SPARK_CORE_ID}}",
> "published" : "{{SPARK_PUBLISHED_AT}}",
> "event" : "{{SPARK_EVENT_NAME}}"
> },
> "noDefaults": true,
> "mydevices": true
> 
> ```
> 
> }

Thanks. It appears that it is parsing correctly. Because I was logging the json to the console and running it through JSONLint, I assumed it was invalid (well I guess technically it is), I was heading down the road of correcting it. After reading what you posted, I started writing the json to a file and of course it is working. Thanks for the response!
