- Home /
Get information from response
Hi everyone.
How can i get information from something like that? for example i need to get "title". i need use string class?
{
"meta": {
"status": 200,
"msg": "OK"
},
"response": {
"blog": {
"title": "David's Log",
"posts": 3456,
"name": "david",
"url": "http:\/\/david.tumblr.com\/",
"updated": 1308953007,
"description": "<p><strong>Mr. Karp<\/strong> is tall and skinny, with
unflinching blue eyes a mop of brown hair.\r\n
He speaks incredibly fast and in complete paragraphs.</p>",
"ask": true,
"ask_anon": false,
"likes": 12345
}
}
}
Comment
Thats JSON
How you access it depends on what language you are writing in.
You can use Json.NET and 'deserialize' it into a dictionary. You'll have to use the dynamic type since some of the values will be key:value pairs as well which normally won't fit into a dictionary of 2 types. I've never referenced DLLs in Unity so I'm not sure how it works but this page seems to explain it.
An example of using it would be this:
using Newtonsoft.Json;
Dictionary<string,dynamic> json = JsonConvert.DeserializeObject<Dictionary<string,dynamic>(text);
Debug.Log(json["response"]["blog"]["title"]);
//Should be "$$anonymous$$'s Log"
It's kind of long and ugly but it works. You might have to cast it to a string when using the dynamic type. I should note it's in C#.
Your answer
![](https://koobas.hobune.stream/wayback/20220613144738im_/https://answers.unity.com/themes/thub/images/avi.jpg)