0

I've used Insomnia to send a json file ('json_information') to app django.

{
"company": 2,
"value": 0.15,
"date": "2020-01-01",
"default": "False",
"active": "False",
"list": [
{
"sku": "A1B2C3",
},
{
"sku": "D4E5F6",
},
{
"sku": "G7H8I9",
},
{
"sku": "J0K1L2",
},
],
}

The python code to load this json fails:

data = json.loads(request.data['json_information'], strict=False)

The error:

json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 11 column 1 (char 181)

Any idea?

3
  • 1
    The trailing commas make the JSON invalid Commented Jul 18, 2020 at 2:20
  • That's not json. How was the string creatred? Commented Jul 18, 2020 at 2:21
  • It is valid python. JSON and python literals are a bit different. Commented Jul 18, 2020 at 2:23

1 Answer 1

1

The trailing commas are not supported by the json module.

{
"company": 2,
"value": 0.15,
"date": "2020-01-01",
"default": "False",
"active": "False",
"list": [
{
"sku": "A1B2C3", <-- This one
},
{
"sku": "D4E5F6", <-- This one
},
{
"sku": "G7H8I9", <-- This one
},
{
"sku": "J0K1L2", <-- This one
}, <-- This one
], <-- This one
}

See this other answers for alternatives

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.