Reputation: 1703
In my project, client send a json string back to server side. Below is parts of the json string.
"xy":[170,226],"cell":[["catalog_2","catalog_2"],["input_423","423"],["input_421","421"]]
On server side, I try to parse the json string into custom object. But I don't know which type can express the cell and xy property?
Please help, thanks.
Ps : I use JavaScriptSerializer to parse the json string.
Upvotes: 2
Views: 89
Reputation: 32702
public class RootObject
{
public List<int> xy { get; set; }
public List<List<string>> cell { get; set; }
}
It's a simply a list of ints, and then a list of list of strings. I don't think that's what you want, but that's unfortunately what you get due to how the JSON is structured. Perhaps "xy" should be a nested object and not an array? Do you have any control over the JSON?
By the way, I generated that object with json2csharp.
Upvotes: 0
Reputation: 16413
The yx
property contains an array of int
so you can use either int[]
or List<int>
the cell
property is an array of arrays which are strings. Using the JSON to C# converter yields the following class:
public class RootObject
{
public List<int> xy { get; set; }
public List<List<string>> cell { get; set; }
}
Upvotes: 1