This shows you the differences between two versions of the page.
Next revision | Previous revision Next revision Both sides next revision | ||
manual:JSON [2019/06/24 00:33] peternlewis created |
manual:JSON [2019/06/24 05:01] peternlewis [Pretty, Compact and Strict Flags] |
||
---|---|---|---|
Line 38: | Line 38: | ||
* 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”. And important distinction is that the first one is a numeric calculation, the second one is plain text, and the third one is token text. |
===== Pretty, Compact and Strict Flags ===== | ===== Pretty, Compact and Strict Flags ===== | ||
Line 51: | Line 52: | ||
{"a":3,"b":null} | {"a":3,"b":null} | ||
- | whereas the result of %JSONValuePretty%J%` will be: | + | whereas the result of `%JSONValuePretty%J%` will be: |
{ | { | ||
Line 58: | Line 59: | ||
} | } | ||
- | The exact indentation should not be assumed, it might be any number fo spaces or tabs. | + | The exact indentation should not be assumed, it might be any number of spaces or tabs. |
The Strict flag relates only to JSON results that are trivial JSON strings, eg JSON `"result"`. | The Strict flag relates only to JSON results that are trivial JSON strings, eg JSON `"result"`. | ||
Line 78: | Line 79: | ||
The default result format is Compact, Non-Strict. | The default result format is Compact, Non-Strict. | ||
+ | ===== Use ===== | ||
+ | There are [[:Actions|actions]] to set dictionaries or variables from JSON containers, as well as an [[:action: Set_JSON_Value|action]] to set a field within a JSON object to a specified value. | ||
===== Notes ===== | ===== Notes ===== | ||
Line 84: | Line 87: | ||
JSON objects must be properly legal to be processed. In particular keys to objects must be strings, which means strings must be quoted with double quotes. `{ a : 3 }` is not valid, it must be `{ "a" : 3 }`. | JSON objects must be properly legal to be processed. In particular keys to objects must be strings, which means strings must be quoted with double quotes. `{ a : 3 }` is not valid, it must be `{ "a" : 3 }`. | ||
- | Although `3` and `"a"` are technically legal JSON, in cases of ambiguity, Keyboard Maestro will not consider a variable to contain JSON unless it is a container, ie an array or dictionary, which starts (without any leading white space) with a `{` or `[`, and ends with a matching bracket followed by optional white space. | + | Although `3` and `"a"` are technically legal JSON, in Non-Strict mode with cases of ambiguity, Keyboard Maestro will not consider a value or variable to contain JSON unless it is a container, ie an array or dictionary, which starts (without any leading white space) with a `{` or `[`, and ends with a matching bracket followed by optional white space. |