1

So I have a program that has to constantly update different values of different Json files. I'm using Newtonsoft.Json, and I know I can modify a Json file as follows:

jsonObject["Object1"]["Object2"]["key"] = "new value";

This works great, but I'd hate to have to list all different possibilities, and basically have a function for each different location. I was trying to create a function that could take the value path as an array of strings kind of like this:

string[] valueJsonPath = { "Object1", "Object2", "key"}

I thought I would be able to use a for loop to get the right JToken, and then just modify that. However this didn't work.

So my question is this: How can I make a function that will take the path to the value as a parameter?

Thanks in advance guys!

Felipe Centeno
  • 2,911
  • 1
  • 21
  • 39

0 Answers0