Since you’re specifically working with JSON there are a couple of other things you might want to be aware of. First of all you may want to look at the JSONFormat() and JSONValue() functions which will convert any SenseTalk values (strings, lists, property lists, etc.) to or from JSON format.
Also, the JSON format is highly compatible with SenseTalk, so if you happen to have a data structure in JSON format you can copy and paste it directly into a script and it should work. The only exception is strings containing escape codes like
– SenseTalk treats quoted strings as literal values, so if your JSON data uses escape codes you’ll need to use the JSONValue() function to correctly convert those into SenseTalk data.
Here’s an example, with JSON data copied and pasted directly from the Wikipedia page on JSON:
set person to {
"firstName": "John",
"lastName": "Smith",
"age": 25,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": 10021
},
"phoneNumbers": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "fax",
"number": "646 555-4567"
}
]
}
put person