2

I get back JSON in this format:

{key1:"value1", key2:"value2"} 

If I try to use JSON::XS' decode_json method to convert it for me but it's complaining that the keys are not quoted. Is there an option I can set in JSON::XS to ignore this quirk? I looked at the docs but there was nothing obvious.

gdanko
  • 1,732
  • 4
  • 18
  • 30

1 Answers1

5

If you don't quote the keys, it's not valid JSON. A valid JavaScript object is not necessarily a valid JSON object.

See this answer.

JSON::PP has options to allow for more lax parsing of "JSON"-ish input, specifically the allow_barekey option.

Community
  • 1
  • 1
zostay
  • 3,935
  • 19
  • 30