I have a json string that is fetched by a web page. The json’s schema is like this:
string schema = @"{
'description': 'A person',
'type': 'object',
'properties':
{
'error':
{
'type': 'object',
'properties':
{
'code': { 'type': 'integer' },
'message': { 'type': 'string' }
}
},
'response':
{
'type': 'object',
'properties':
{
'code': { 'type': 'integer' },
'status': { 'type': 'string' },
'message': { 'type': ['string', 'object'] , 'items': {'type': 'string'}}
}
}
}
}";
Everything is okay and the json is valid now.
For now, I want to convert a part of the json string to an array to loop throw it and put the data to a Grid.
The part that I told is like this:
[{\"id\":\"1\",\"task\":\"some message here...\",\"sender\":\"123qwe\",\"time\":\"1356136733\"}, [{\"id\":\"1\",\"task\":\"some message here...\",\"sender\":\"123qwe\",\"time\":\"1356136733\"}, ....
To access it , I use this:
var messages = (string)o["response"]["message"];//o is a JObject
Thanks in Advance!
I figured out this by using dynamic type…: