- Home /
JSON Seriallize facebook name
I want to get the JSON data on Facebook, I got the name but it's returning a JSON, how can I transform the JSON name to a string ? This is a print of what i get:
Ignore the *"Nome = "*
this is mine input, I have {"name": "Maria...", "id":
"1000...."}
How can I get this names on a string: actually this is part of my code:
public void GetUserName()
{
FB.API("me?fields=name", Facebook.HttpMethod.GET, Callback);
}
void Callback(FBResult result)
{
texto.guiText.text = ("Nome = " + result.Text);
}
Answer by fafase · Feb 06, 2014 at 05:31 PM
Just parse the Json, either use a parser like SimpleJson or do your own parser with some string substring and search for a string within a string.
I know that I need to parse, but I have no idea how to do, tried to use SimpleJson but I don't understood anything
Well your Json file is nothing but a long string. So if you know what information you are after you can simply develop a method that will look for the name and return what comes next. First get the index where "name" appear then get the chars starting from index + 8 ( name": ") and then get all that comes until the next ". That is your name.
Worked ! Thank you! $$anonymous$$y code: var N = JSON.Parse(result.Text); var name = N["name"]; texto.guiText.text = (name);
Your answer
![](https://koobas.hobune.stream/wayback/20220613132723im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
I want to convert image data(Texture2D) to Base64 string and store in JSON file in Unity3D(C#). 0 Answers
Facebook SDK for Unity: check if an invite has been sent and give award to the player 1 Answer
Parse Json Response through Dictionary object 1 Answer
Parsing Json from facebook? 1 Answer
Facbook Authentication token 0 Answers