stefankoegl / python-json-pointer

Resolve JSON Pointers in Python
https://python-json-pointer.readthedocs.org/
Other
140 stars 43 forks source link

Adding elemente to array #33

Closed mathiasbrito closed 6 years ago

mathiasbrito commented 6 years ago

Add operations with - at the of the path intending to insert a new value in a array is implemented?

from: http://jsonpatch.com/

Add
{ "op": "add", "path": "/biscuits/1", "value": { "name": "Ginger Nut" } }
Adds a value to an object or inserts it into an array. In the case of an array, the value is inserted before the given index. The - character can be used instead of an index to insert at the end of an array.

When trying to do so "path": "/biscuits/-", ex:

 [
 {
    "op": "add",
    "path": "/biscuits/-",
    "value": "bono"
  }
]

I get:

list indices must be integers or slices, not str

Am I doing something wrong or the feature is not implemented?

mathiasbrito commented 6 years ago

sorry, mixed up json-pointer/json-patch...