Jump to content

Can you specify the ordering of a new label in JSON patching?


Tristan Perotti

Recommended Posts

I'm trying to add a new entry to a "texturesByType" object for the flower block.  But I believe my patched label is added at the end of the object, after the wildcard.  So the pattern matching is selecting the wildcard entry instead of my new one because it matches first.  This is my hunch anyway.  I was able to work around this by first removing the wildcard label, adding my new texture by type, then replacing the wildcard. 

Is there a way to specify the order of the new label you are patching into the object?

Link to comment
Share on other sites

You can't specify the order in this case, so I'm assuming you used this common technique for moving a wildcard out of the way and then putting it back again. The temporary destination path "hax" is just a made up location. It can be any arbitrary name really.

You can put your patch first, and then these two patches afterwards.  Or put your patch between these two. Either way works.

[
 {
    "file": "game:itemtypes/resource/stone.json",
    "op": "move",
    "frompath": "/texturesByType/*",
    "path": "/hax",
  },
  {
    "file": "game:itemtypes/resource/stone.json",
    "op": "move",
    "frompath": "/hax",
    "path": "/texturesByType/*",
  }
]
Edited by Spear and Fang
Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.