1

I have some JSON returned inthe format of :

[{
"Strains":[{
    "Description":"String content"
    }],
"Description":"String content"
}]

Where there is a one to many relationship between the Description and the Strains. I want to parse this into a Dictionary<string, List<string>>, could somebody please advise what I should be looking at to achieve this?

Thanks.

EDIT:

I've tried deserializing as such:

JsonDeserializer des = new JsonDeserializer();
var foo = (List<Dictionary<string, object>>)des.DeserializeObject(json);

However, no joy. I'm just having a play with JSON.net, to see if there's anything there that helps.

0

1 Answer 1

3

I think it's failing because technically it's not a straight cast to a Dictionary<string, object>. The "Strains" property is an object, whilst the "Description" property could be mapped as a KeyValuePair

You'll need to deserialize this to an object. Have you tried Json.NET?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.