Jump to content
Korean Random

Can I overwrite a portion of json object already called by reference ("$")?


Go to solution Solved by Genba_Kantoku_s,

Recommended Posts

I am making a config but it tweaks very small portion of lengthy .xc files from default config.

 

What I tried was, (within @xvm.xc)

 

  "login": ${"../default/login.xc":"login"},
  "login.pingServers": ${"hangar.xc":"hangar.pingServers"},
  "login.onlineServers": ${"hangar.xc":"hangar.onlineServers"},

 

but it did not work and only "login" part was executed.

 

What I wanted is, all the other parts of "login" object refers to the default folder, but only two objects are from my own config.

 

Again I tried 

 

  "login": {
    ${"../default/login.xc":"login"},
    "pingServers": ${"hangar.xc":"hangar.pingServers"},
    "onlineServers": ${"hangar.xc":"hangar.onlineServers"}
  },

 

but this resulted in error because "$" reference was illegal to be within anywhere but the value position.

 

Then I tried

 

  "login": ${"../default/login.xc":"login"},
  "login": {
    "pingServers": ${"hangar.xc":"hangar.pingServers"},
    "onlineServers": ${"hangar.xc":"hangar.onlineServers"}
  },

 

but this caused only the last statement is executed, former ones are totally overwritten.

 

How can I do? I want to do something similar to 'monkey patch' but within one .xc file.

  • Upvote 1
Link to comment
Short link
Share on other sites

  • Solution

Found the solution by my own.

The correct code is

 

  "login": {
    "allOf": [${"../default/login.xc":"login"}],
    "pingServers": ${"hangar.xc":"hangar.pingServers"},
    "onlineServers": ${"hangar.xc":"hangar.onlineServers"}
  },

 

This is because all reference ("$ref" or xvm's "${"file":"path"}) have a property to nullify any other sister objects.

By putting it into "allOf": [(array)] we can detour this.

  • Upvote 2
Link to comment
Short link
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...