Chatar Veer Suthar
Chatar Veer Suthar

Reputation: 15639

JSON is not valid?

Can any make this json correct, I am inserting json in JSON online Validator

Getting error that json is not valid, what is error in this json, and how can I make it correct, please don't give links of other tutorials, Thanks

{
    mothmap: {
        value: [{
            longitude: -0.13025200000004133,
            latitude: 51.4596619
        }, {
            longitude: -2.707384100000013,
            latitude: 53.7613383
        }]
    }
 }

Upvotes: 0

Views: 32561

Answers (7)

Tim S.
Tim S.

Reputation: 13853

JSONLint requires properties to be written in quotes:

{
    "mothmap": {
        "value": [
            {
                "longitude": -0.13025200000004133,
                "latitude": 51.4596619
            },
            {
                "longitude": -2.707384100000013,
                "latitude": 53.7613383
            }
        ]
    }
}

However, yours was perfectly valid. JSONLint just complains too much.

Upvotes: 1

Thomas Clayson
Thomas Clayson

Reputation: 29935

If you're using a validator, why didn't you bother to look at the output!

It says:

Parse error on line 1:
{    mothmap: {        
-----^ Expecting 'STRING', '}'

EXPECTING STRING means its looking for a string..........

put all the bits BEFORE the :s inside double quotes...

eg: { "mothmap": { .....

Upvotes: 1

Molochdaa
Molochdaa

Reputation: 2218

Like this :

{
    "mothmap": {
        "value": [
            {
                "longitude": -0.13025200033,
                "latitude": 51.4596619
            },
            {
                "longitude": -2.70738400013,
                "latitude": 53.7613383
            }
        ]
    }
}

Upvotes: 0

railwayparade
railwayparade

Reputation: 5156

{
    "mothmap": {
        "value": [
            {
                "longitude": -0.13025200000004133,
                "latitude": 51.4596619
            },
            {
                "longitude": -2.707384100000013,
                "latitude": 53.7613383
            }
        ]
    }
}

Strings need to be in quotes.

Upvotes: 2

Raidok
Raidok

Reputation: 764

All strings must be in quotes, key's included.

Upvotes: 0

LeleDumbo
LeleDumbo

Reputation: 9340

A valid json has its key quoted, just like string values.

Upvotes: 0

David Alber
David Alber

Reputation: 18121

You need double quotes around your strings. This passes the validator:

{
    "mothmap": {
        "value": [
            {
                "longitude": -0.13025200000004133,
                "latitude": 51.4596619
            },
            {
                "longitude": -2.707384100000013,
                "latitude": 53.7613383
            }
        ]
    }
}

Upvotes: 5

Related Questions