Delete (Json function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Automatically generated page update)
 
No edit summary
Line 1: Line 1:
{{Template:Json:Delete subtitle}}
{{Template:Json:Delete subtitle}}
 
This function deletes an item from a Json array or object.
This page is [[under construction]].
==Syntax==
==Syntax==
{{Template:Json:Delete syntax}}
{{Template:Json:Delete syntax}}
Line 8: Line 7:
<tr><th>%number</th><td>number</td></tr>
<tr><th>%number</th><td>number</td></tr>
<tr><th>Json</th>
<tr><th>Json</th>
<td>Json object, which may be <var>Null</var></td></tr>
<td>Json object, which must be either an array or obvject.</td></tr>
<tr><th>nonObject</th>
<tr><th>nonObject</th>
<td>NonObject</td></tr>
<td>NonObject</td></tr>
</table>
</table>
==Usage notes==
==Usage notes==
<ul>
<li>If the json object is neither an array nor an object an InvalidJsonType exception is thrown.</li>
<li>Attempting to delete an item number not in an array results in request cancellation whereas deleting an object name not in the object is simply a no-op.</li>
<li>Deleting an item from the middle of an array or object simply shifts subsequent items down. This means that subsequent items after a delete are accessed by a number one less than before. This only affects objects (as opposed to arrays) when their items are access by the [[ItemByNumber (Json function)|ItemByNumber function]] and does not affect the more common case where they are accessed by name.</li>
<li>Deleting an item from an array or object does not delete that object unless the only reference to the object is the one being deleted.</li>
</ul>
==Examples==
==Examples==
==See also==
==See also==
{{Template:Json:Delete footer}}
{{Template:Json:Delete footer}}

Revision as of 22:16, 17 February 2015

Delete a JSON object/array item value (Json class)

[Introduced in Model 204 7.6]

This function deletes an item from a Json array or object.

Syntax

[%number =] json:Delete( index) Throws InvalidJsonType

Syntax terms

%numbernumber
Json Json object, which must be either an array or obvject.
nonObject NonObject

Usage notes

  • If the json object is neither an array nor an object an InvalidJsonType exception is thrown.
  • Attempting to delete an item number not in an array results in request cancellation whereas deleting an object name not in the object is simply a no-op.
  • Deleting an item from the middle of an array or object simply shifts subsequent items down. This means that subsequent items after a delete are accessed by a number one less than before. This only affects objects (as opposed to arrays) when their items are access by the ItemByNumber function and does not affect the more common case where they are accessed by name.
  • Deleting an item from an array or object does not delete that object unless the only reference to the object is the one being deleted.

Examples

See also