json.fields: Difference between revisions
Jump to navigation
Jump to search
Verisimilar (talk | contribs) m (Correcting JSON Array link.) |
Bone White (talk | contribs) m (Added line explaining that JSON Objects are unordered) |
||
Line 7: | Line 7: | ||
* If the delimiter ''"json"'' then a [[JSON Array]] is returned. | * If the delimiter ''"json"'' then a [[JSON Array]] is returned. | ||
* Otherwise a [[Macros:string list|string list]] is returned with the delimiter passed in. | * Otherwise a [[Macros:string list|string list]] is returned with the delimiter passed in. | ||
Note: Because [[JSON Object]]s are unordered, ''json.fields'' will not reflect the order they were set in. | |||
|usage= | |usage= |
Revision as of 00:34, 30 November 2011
json.fields() Function
• Introduced in version 1.3b49
Returns the fields (keys) for a JSON Object or the indexes for a JSON Array as a string list. The type of the value returned depends on the delimiter parameter.
- If the delimiter is not specified then a string list is returned with the default value of ',' is used.
- If the delimiter "json" then a JSON Array is returned.
- Otherwise a string list is returned with the delimiter passed in.
Usage
[h: strList = json.fields(jobj)]
[h: strList = json.fields(jobj, delim)]
[h: jobj = json.fields(jobj, 'json')]
Example
[h:a=json.fromStrProp("a=1;b=44;c=12")] [r:json.fields(a)]
[h:a=json.fromList("a,1,g,4")][r:json.fields(a)]
[h:a=json.fromStrProp("a=1;b=44;c=12")] [r:json.fields(a, "json")]
Returns
a,c,b 0,1,2,3["a","c","b"]