Article - CS284022

In Thingworx Platform, String to JSON conversion failed with error: JSON Parse Unexpected Token Error

Modified: 10-Aug-2022   


Applies To

  • ThingWorx Platform 8.0 F000 to 9.3

Description

  • Trying to parse a string into JSON in service:
var testString = "";
testString = "{'key': 'value'}";

var testJSON = JSON.parse(testString);
var result = testJSON;
  • Causes error:
SyntaxError: Unexpected token: o (JSONErrorTest#5)
This is a printer-friendly version of Article 284022 and may be out of date. For the latest version click CS284022