Parsing JSON object containing an array with Windows Phone 7

前端 未结 3 1244
终归单人心
终归单人心 2021-01-14 17:36

Ok, I\'m having some difficult with this.

My JSON is like

{ \"names\" : [ {\"name\":\"bla\"} , {\"name\":\"bla2\"} ] }

I was trying

3条回答
  •  情深已故
    2021-01-14 18:00

    I'm using JSON.NET ( http://james.newtonking.com/projects/json-net.aspx ) normally, so my code might vary a bit.

    For the list content I would go for a class with a name property like that:

    public class NameClass {
        public string name { get;set; }
    }
    

    Then you should be able to deserialize with JSON.NET a List:

    List result = JsonConvert.Deserialize>(jsonString);
    

    This is written out of my head, so maybe, it doesn't compile with copy and paste, but it should work as a sample.

提交回复
热议问题