@JSONINSERTVALUE[xpath,value,type,position] : Inserts the specified value at the selected position.


Value specifies the new value.

Type specifies the type of the value. Possible values are:

0 (Object)

1 (Array)

2 (String)

3 (Number)

4 (Bool)

5 (Null)

6 (Raw)


The Position parameter specifies the position of Value relative to the element specified by XPath. Possible values are:

0 (Before the current element)

1 (After the current element)

2 (The first child of the current element)

3 (The last child of the current element)


The JSON file must have been opened with a previous call to @JSONOPEN.


Returns 0 on success, or a JSON error code on failure.


For example, if you have a JSON file like this:



 "store": {

   "books": [


       "category": "reference",

       "author": "Nigel Rees",

       "title": "Sayings of the Century",



       "category": "fiction",

       "author": "Evelyn Waugh",

       "title": "Sword of Honour",







To add a new book to the array:


echo %@jsoninsertvalue[/json/store/books,"",0,3]

echo %@jsoninsertproperty[/json/store/books/[3],"category","fiction",2,3]

echo %@jsoninsertproperty[/json/store/books/[3],"author","Herman Melville",2,3]

echo %@jsoninsertproperty[/json/store/books/[3],"title","Moby Dick",2,3]

JSON Errors

10231   Unbalanced element tag

10232   Invalid JSON markup

10233   Invalid XPath

10234   DOM tree unavailable

XMLp Errors

101   Invalid attribute index

102   No attributes available

103   Invalid namespace index

104   No namespaces available

105   Invalid element index

106   No elements available

107   Attribute does not exist

201   Unbalanced element tag

202   Unknown element prefix (can't find namespace)

203   Unknown attribute prefix (can't find namespace)

204   Invalid XML markup

205   Invalid end state for parser

206   Document contains unbalanced element

207   Invalid XPath

208   No such child

209   Top element does not match start of path

210   DOM tree unavailable

302   Can't open file.