manual:JSON
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| manual:JSON [2019/06/24 04:49] – peternlewis | manual:JSON [2024/04/22 02:23] (current) – peternlewis | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== JSON ====== | ====== JSON ====== | ||
| - | Keyboard Maestro | + | Keyboard Maestro includes comprehensive support for [[https:// |
| JSON objects consist of one of: | JSON objects consist of one of: | ||
| Line 8: | Line 8: | ||
| * A dictionary (aka, object), surrounded by curly brackets with comma-separated key-value pairs, eg `{ " | * A dictionary (aka, object), surrounded by curly brackets with comma-separated key-value pairs, eg `{ " | ||
| * A double quoted string, eg `" | * A double quoted string, eg `" | ||
| + | * A number. | ||
| * `true` - boolean true | * `true` - boolean true | ||
| * `false` - boolean false | * `false` - boolean false | ||
| Line 30: | Line 31: | ||
| * “.” followed by the field name. Field names are trimmed of leading or trailing whitespace - if your object field names can start or end with white space, you need to use the `{ field name }` notation. | * “.” followed by the field name. Field names are trimmed of leading or trailing whitespace - if your object field names can start or end with white space, you need to use the `{ field name }` notation. | ||
| - | Array indices are 1-based. | + | Array indices are 1-based. Negative indices count from the end of the array. The 0 index of an array access will return the count of the number of entries |
| Keyboard Maestro will use arrays and dictionaries more or less interchangeably, | Keyboard Maestro will use arrays and dictionaries more or less interchangeably, | ||
| Line 38: | Line 39: | ||
| * J{3} | * J{3} | ||
| - | will all return the third element of an array, or the dictionary value for key “3”. | + | will all return the third element of an array, or the dictionary value for key “3”. |
| ===== Pretty, Compact and Strict Flags ===== | ===== Pretty, Compact and Strict Flags ===== | ||
| Line 45: | Line 45: | ||
| Many of Keyboard Maestro’s operations that produce a result from JSON have two flags associated with them: Compact or Pretty; Strict or Not-Strict. | Many of Keyboard Maestro’s operations that produce a result from JSON have two flags associated with them: Compact or Pretty; Strict or Not-Strict. | ||
| - | * Compact means all extraneous white space is omitted from JSON results | + | * Compact means all extraneous white space is omitted from JSON results. |
| * Pretty means JSON results will include white space to format the JSON in a relatively readable manner. | * Pretty means JSON results will include white space to format the JSON in a relatively readable manner. | ||
| Line 52: | Line 52: | ||
| {" | {" | ||
| - | whereas the result of %JSONValuePretty%J%` will be: | + | whereas the result of `%JSONValuePretty%J%` will be: |
| { | { | ||
| Line 59: | Line 59: | ||
| } | } | ||
| - | The exact indentation should not be assumed, it might be any number | + | The exact indentation should not be assumed, it might be any number |
| The Strict flag relates only to JSON results that are trivial JSON strings, eg JSON `" | The Strict flag relates only to JSON results that are trivial JSON strings, eg JSON `" | ||
| - | * Strict means even for trivial JSON strings, the result will be a properly double quoted string (eg `" | + | * Strict means even for trivial JSON strings, the result will be a properly double quoted string (eg `" |
| * Non-Strict means that for trivial JSON string results, the result will return just the resulting string without any double quotes and with any escaping removed/ | * Non-Strict means that for trivial JSON string results, the result will return just the resulting string without any double quotes and with any escaping removed/ | ||
| Line 75: | Line 75: | ||
| " | " | ||
| | | ||
| - | The Strict/ | + | The Strict/ |
| The default result format is Compact, Non-Strict. | The default result format is Compact, Non-Strict. | ||
| - | ===== Actions | + | ===== Use ===== |
| + | There are [[: | ||
| ===== Notes ===== | ===== Notes ===== | ||
| Line 87: | Line 87: | ||
| JSON objects must be properly legal to be processed. | JSON objects must be properly legal to be processed. | ||
| - | Although | + | Decimal numbers may be processed by the system JSON APIs, which will store them as floating point, and floating point cannot store all decimal numbers with full fidelity. For example, if variable |
| + | Although `3` and `" | ||
manual/JSON.1561351740.txt.gz · Last modified: by peternlewis
