The statement is used to produce a JSON text representation of the target of the directed path field. The directed path field must refer to a container or any array or object item in a container. The JSON text is saved to a specified named variable. The text will be pretty unless the Compress option is set. Note that standard JSON representation is used even if the data originated as JSON5.
All text fields in the statement can contain any of the escape sequences defined in Escape Sequences.
The action test state will be set to true if there are no errors. The action test state will be false if any errors occurred. Named variable Container Error will contain the errror text. If the Stop action on error option is enabled, the action will be terminated with an error message in the case of an error.
Example:
Create container 'sample' from JSON text '{"list":["Hello World","All Done"]}' Extract JSON text from the container item at 'sample.list' to named variable 'result'
The above example will set named variable result to:
[ "Hello World", "All Done" ]
Yate containers are intended to be mappings to JSON data. However, Mac plist files can contain the additional data types of dates and data which cannot be represented as such in JSON. When reading a plist file with the Read/Write Plist File statement, dates and data types are retained. When converting a container to JSON text, these data types are converted to Strings.