Facebook.MiniJSON Deserialize comments and nested values under from returning no values.
Good day,
We are using a FB.API call to retrieve the comments on a post, we are unable to retrieve the data nested under "from".
API Explorer command: "10153539873517828/comments?"
C# code
FB.API("/10153539873517828/comments?", HttpMethod.GET, delegate (IGraphResult result)
{
string jsonMessage = result.RawResult;
Debug.Log(jsonMessage);
var soap = Json.Deserialize(jsonMessage) as Dictionary<string,object>;
List<object> entries = soap["data"] as List<object>;
try
{
for (int i = 0; i < soap.Count; i++)
{
Dictionary<string,object> messageData = entries[i] as Dictionary<string,object>;
object resultData = messageData["message"]; (Works)
object resultData = messageData["name"]; (Blank)
Debug.Log("JSON string : " + resultData.ToString());
}
}
catch
{
Debug.Log("Done!!!");
}
});
JSON String:
{
"data": [
{
"created_time": "2016-03-31T11:10:18+0000",
"from": {
"name": "Hello world",
"id": "298062736962722"
},
"message": "Test comment",
"id": "10153539873517828_10153539875377828"
},
{
"created_time": "2016-03-31T11:12:47+0000",
"from": {
"name": "Hello world",
"id": "298062736962722"
},
"message": "people must be wonder what the bleep is this, lol.",
"id": "10153539873517828_10153539877202828"
}
],
"paging": {
"cursors": {
"before": "WTI5dGJXVnVkRjlqZAFhKemIzSTZANVEF4TlRNMU16azROelV6TnpjNE1qZAzZANVFExT1RReU1qWXhPQT09",
"after": "WTI5dGJXVnVkRjlqZAFhKemIzSTZANVEF4TlRNMU16azROemN5TURJNE1qZAzZANVFExT1RReU1qYzJOdz09"
}
}
}
We can successfully get the "message" and "id" under "data" when trying to get the "name" and the associated "id" it returns blank values.
We have read many post and had a look at some of the solution people have posted and we have not found anything that has helped to resolve the issue.
As we are using the FB SDK it would stand to reason that we should be able to use the Facebook.MiniJSON to deserialize the above string. Retrieving:
{
"created_time": "2016-03-31T11:10:18+0000",
"from": {
"name": "Hello world",
"id": "298062736962722"
},
"message": "Test comment",
"id": "10153539873517828_10153539875377828"
},
All the example on the developer documentation only cover first level retrieval, how can we fix this?
Answer by Jean-Pierre-DP · Apr 12, 2016 at 04:20 PM
Hi
Found a solution, looks like it is not possible using Facebook.miniJSON
https://www.assetstore.unity3d.com/en/#!/content/710
Able to access all values using the above plugin.
Hi
Found a solution that works with Facebook.$$anonymous$$iJSON
big thank you to $$anonymous$$Brzozowski
Your answer
Follow this Question
Related Questions
Getting Player Picture with bad request in unity 5 1 Answer
FaceBook sdk Error Coding 0 Answers
IAP gives ERROR_BROKEN_PIPE 3 Answers
firebase - Facebook authentication invalid access_token error code 43 1 Answer
Facebook GameRoom 0 Answers