Help forum

How to update deep value in json tree

  • SkiinBerlin

    1 year ago

    I'm building a self referencing component where you can add sub objects indefinitley. I got it work! But the issue im having now is how to handle edits to the object. Lets say im a few levels in the json, and change a value. This level has no knowledge about its parents. So i try to send the data up, but sending the data up a level is on the child object, but that is the same component as the parent object. so aaaahh im really confused. here's what i have so far. i tried with events and stuff but still wasnt able to get it working: https://editor.nordcraft.com/projects/sapphire_bossk_gastric_panda/branches/start/components&sourceid=chrome&ie=UTF-8&sei=_w9TaNTuFPrAi-gP9ZOY8Qg

    The end goal is that the json will be a value in a table. so any change done visually, will get sent to the db and then be reflected in the builder.

    Thanks!
  • MVvdV

    1 year ago

    you have to pass in the entire JSON tree again and use the Find, Get and Set functions to drill down into each level, so you work backwards, image is just and example.
    1385084785512153118-Screenshot_2025-06-19_at_12.31.01.png
  • Andreas Møller

    1 year ago

    Det can take an array as the second input for setting deep properties
  • SkiinBerlin

    1 year ago

    I dont understand...
    I find the the entire subobject (with its subobjects) and replace it somehow?
  • Tod

    1 year ago

    Great job @SkiinBerlin! Your contribution to the Nordcraft Community just made you advance to Community Level 1! 🌲
  • Andreas Møller

    1 year ago

    Say you have this object
    1385208156346519613-CleanShot_2025-06-19_at_12.42.302x.png
  • An I want to change Kaspers name property
  • 1385208375041851432-CleanShot_2025-06-19_at_12.43.162x.png
  • Now he is Super kasper
  • SkiinBerlin

    1 year ago

    I see... but i feel like my situation is different because the deep object has no knowledge of the full object, just it's values/properties. Imagine the Simple Json viewwer you built. How would you add the evility to edit values within that json viewer? if its a nested object.
  • it feels more complex, but maybe its just a lack of understanding
  • MVvdV

    1 year ago

    you can get another mechanic to 'find' the object you need to change, you can get the item from an event like currentTarget from mouse event or you can get element by ID and use its properties to find itself in your JSON structure.