Hi,
I use System.Json and the following code to parse a JSON string in the core part of my app :
var json = JsonValue.Parse(myStringJson);
var data = json["data"];
foreach (var dataItem in data)
{
string myValue = dataItem.Value["myKey"]; //Here is the compilation error
//...
})
Everything is OK when I test it in a C# class Library project. But when I try to use it in a Xamarin Android Library Project, I have a compilation error.
The compilation return the following error : 'object' does not contain a definition for 'Value' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?).
If I use :
foreach (KeyValuePair<Object, JsonValue> dataItem in data)
... The compilation is OK but I have an illegal cast exception during the execution.
What is the solution to use System.Json (I don't want to use any other component like JSON.NET) ?
Note : the JSON comes from the Facebook graph API and this is its structure :
{
"data" : [{
"id" : "xxxxxxxxxxxxx",
"from" : {
"id" : "xxxxxxxxxxxxx",
"category" : "xxx",
"name" : "xxx"
},
"message" : "the message...",
"privacy" : {
"value" : ""
},
"type" : "status",
"status_type" : "mobile_status_update",
"application" : {
"name" : "Facebook for Android",
"namespace" : "xxxx",
"id" : "xxxx"
},
"created_time" : "2013-06-01T16:45:04+0000",
"updated_time" : "2013-06-02T08:32:01+0000",
[...]
I want to retrieve the message, name, type and created_time tags.
Thanks in advance :)