❔ Convert nested JObjects into Dictionary<string, object>
What I want is like the title, to convert any json given by the user into a
So I figured I'd start recursively, in a sense, but I am getting stuck on the point where I attack the child tokens, since they are JToken and not JObject. And I'm not sure if they will keep working if I use
Here's what I've got so far:
but as you can see I'm not doing anything with childTokens at the moment because I'm not sure how to keep the original JSON structure
The reason I am trying to convert it, is because I have to do two of these mappings, and then map user-given keys of the one JSON object to the other (the values)
So this part:
Please halp with my recursive function to map any json into a dictionary
And afterwards, but this is optional for me, a query question
Dictionary<string, object> but keep the JSON structure. Especially if it's nested.So I figured I'd start recursively, in a sense, but I am getting stuck on the point where I attack the child tokens, since they are JToken and not JObject. And I'm not sure if they will keep working if I use
OfType<JObject>(). So I could use some help converting a JObject that a user inputs to a Dictionary that keeps the JSON structure.Here's what I've got so far:
but as you can see I'm not doing anything with childTokens at the moment because I'm not sure how to keep the original JSON structure
The reason I am trying to convert it, is because I have to do two of these mappings, and then map user-given keys of the one JSON object to the other (the values)
So this part:
Please halp with my recursive function to map any json into a dictionary
And afterwards, but this is optional for me, a query question
