0

I want to update a JObject with some values through their JSONPath.

For example: I have this JSON

{
    "lastname": "Butler",
    "phone": [
        123123123,
        141414
    ],
    "address": [
        {
            "addressLine1": "123",
            "addressLine2": "124"
        },
        {
            "addressLine1": "123",
            "addressLine2": "144",
            "additionalInfo": {
                "pin": 123321,
                "landmark": "landmark1"
            }
        }
    ]
}

Here is the info about the paths.

[
    {
        "path":"lastName",
        "value": "Travolta"
    },
    {
        "path": "phone",
        "value": [
            9999999,
            8888888
        ],
    }
    {
        "path":"address[1].addressLine2",
        "value": 123
    },
    {
        "path":"address[2]",
        "value": {
            "addressLine1": "1223",
            "addressLine2": "1242"
        }
    }
]

I want to update/Add the value to json object for all the paths provided using newtonsoft library. The nesting of the paths is not restricted, it go on n levels.

Code-47
  • 413
  • 5
  • 17

0 Answers0