Created
March 11, 2013 20:10
-
-
Save leandrocustodio/5137295 to your computer and use it in GitHub Desktop.
Carregar um JSON no C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string recebeJSON = ""; | |
using (var client = new WebClient()) | |
{ | |
recebeJSON = client.DownloadString("URL do JSON"); | |
} | |
//transforma a string em objeto | |
JObject _recebeJSON = JObject.Parse(recebeJSON); | |
//converte o objeto para que seja acesso atravez de indíces | |
JToken ObjetoJSON = _recebeJSON; | |
/* | |
* Para acessar os objetos do JSON carregado, basta acessar os indíces gerados | |
* no objeto JSON | |
*/ | |
ObjetoJSON["ID"]; | |
ObjetoJSON["nome"]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment