#Correct .patch format for situation?

7 messages · Page 1 of 1 (latest)

heady tinsel
#

I have a file I want to add to that looks like this:

  {
  "materialList" : {
    //template: "Name" : ["materialName", aNumber]
        //Type1 ores
            "mat1" :             ["material1", 1],
            "mat2" :             ["material2", 2],
        //Type2 ores
            "mat3" :             ["material3", 3],
            "mat4" :             ["material4", 4],
        //Type3 ores
            "mat5" :             ["material5", 5]
        }
  }

I would like to add a "mat6" to this list with a .patch file, but can't seem to get formatting correct...

How do?

feral flare
#

Have you tried something like this?
(I'm still an amateur, so I can't promise this will work.)

{ 
"op": "add",
  "path": "/materialList/-",
  "value": { "mat6" : ["material6", 6] }
}
]```
rotund lantern
#

yours would make it

  {
  "materialList" : {
    //template: "Name" : ["materialName", aNumber]
        //Type1 ores
            "mat1" :             ["material1", 1],
            "mat2" :             ["material2", 2],
        //Type2 ores
            "mat3" :             ["material3", 3],
            "mat4" :             ["material4", 4],
        //Type3 ores
            "mat5" :             ["material5", 5],
             {"mat6" : ["material6", 6]}
        }
  }
#

{{}} is invalid

#

it would be valid if materialList were []

#

[{}] is valid