json.set: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Verisimilar (talk | contribs) mNo edit summary |
||
Line 3: | Line 3: | ||
|version=1.3b49 | |version=1.3b49 | ||
|description= | |description= | ||
Sets the value in at the specified index in a [[ | Sets the value in at the specified index in a [[JSON Array]] or for the specified key in a [[JSON Object]]. You can use an empty string ({{code|""}}) to represent a new [[JSON Array]] or [[JSON Object]]. | ||
|usage= | |usage= | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
json.set(jarr, index, value) | |||
</source> | </source> | ||
<source lang="mtmacro" line> | |||
json.set(jarr, index, value, ..., ...) | |||
</source> | |||
<source lang="mtmacro" line> | |||
json.set(jobj, key, value) | |||
</source> | |||
<source lang="mtmacro" line> | |||
json.set(jobj, key, value, ..., ...) | |||
</source> | |||
'''Parameters''' | |||
{{param|jarr|The [[JSON Array]] that has an index's value set.}} | |||
{{param|index|The numeric index which has its value set.}} | |||
{{param|jobj|The [[JSON Object]] that has a key's value set.}} | |||
{{param|key|The named key which has its value set.}} | |||
{{param|value|The content that is set to the {{code|index}} or {{code|key}}.}} | |||
'''Note:''' The {{code|index}} and {{code|value}} parameters or {{code|key}} and {{code|value}} parameters can be repeated in pairs. | |||
|example= | |example= | ||
Line 23: | Line 38: | ||
{"a":5, "b":8} | {"a":5, "b":8} | ||
[8, 3] | [8, 3] | ||
|also= | |||
{{func|json.get}} | |||
}} | }} | ||
[[Category:JSON Function]] | [[Category:JSON Function]] |
Revision as of 05:47, 20 April 2009
json.set() Function
• Introduced in version 1.3b49
Sets the value in at the specified index in a JSON Array or for the specified key in a JSON Object. You can use an empty string (
""
) to represent a new JSON Array or JSON Object.Usage
json.set(jarr, index, value)
json.set(jarr, index, value, ..., ...)
json.set(jobj, key, value)
json.set(jobj, key, value, ..., ...)
Parameters
jarr
- The JSON Array that has an index's value set.index
- The numeric index which has its value set.jobj
- The JSON Object that has a key's value set.key
- The named key which has its value set.value
- The content that is set to theindex
orkey
.
Note: The index
and value
parameters or key
and value
parameters can be repeated in pairs.
Example
[json.set("{}", "a", 5)]
[json.set("", "a", 5, "b", 8)]
[json.set(json.fromList("1,3"), 0, 8)]
Returns
{"a":5} {"a":5, "b":8}[8, 3]