cant access from JSON.Net object properties, items

Mar 28, 2016 at 7:28 PM

have a json array and it will be converted to object by JSON.Net. But when im trying to sue it with;


it fails with result of undefined
Mar 28, 2016 at 8:12 PM
Hi furesoft,

Please provide more info. A code sample would be great. We are not aware of any issues accessing script arrays from the host or vice versa.

Mar 30, 2016 at 4:57 PM
{"content", "hello world"}
var j = Json.parse(result);

Mar 30, 2016 at 6:53 PM
Hi again,

There are several issues with the above. The JSON sample isn't proper JSON, and the code sample (assuming it's JavaScript) seems to have at least one typo and is unlikely to work unless Json is a reference to a custom object of some kind.

Please refer to the working sample below, which uses the console for output (since we're not sure what $alert is):
engine.Script.result = "[{\"content\": \"hello world\"}]";
    var j = JSON.parse(result);
This sample writes "hello world" to the console. Note that if you're using JScript, you'll need WindowsScriptEngineFlags.EnableStandardsMode to enable the standard JSON object.

Good luck!