c# - Parsing JSON key/value pairs with JSON.NET -


i have .net project. i'm using json.net library. need use library parse json. json looks this:

{"1":"name 1","2":"name 2"} 

the object list of key/value pairs. trying figure out how use json.net 1) parse json , 2) loop through key/value pairs. there way this? if so, how?

the thing see de-serializing strongly-typed object.

thank much!

you can deserialize dictionary<string, string>

var dict = jsonconvert.deserializeobject<dictionary<string, string>>(json); foreach(var kv in dict) {     console.writeline(kv.key + ":" + kv.value); } 

since jobject implements idictionary, can use jobject.parse

var dict = jobject.parse(@"{""1"":""name 1"",""2"":""name 2""}"); 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -