반응형
JSON을 통해 JSON의 가치를 얻습니다.그물
http://www.codeplex.com/Json을 사용하여 json 객체에서 값을 추출하려고 합니다.
imdbapi.com을 사용하면 다음과 같이 json이 반환됩니다.
{"Title": "Star Wars", "Year": "1977", "Rated", "PG", "Released", "25 May 1977", "Genre", "Action, Adventure, Fantasy, Sci-Fi "" Director ":" George Lucas "," Writer "," George Lucas "," Actors ":" Mark Hamill, Harrison Ford, Carrie Fisher, Alec Guinness, "" Plot ":" Luke Skywalker leaves his home planet, teams up With Other Rebels, and Tries to save Princess Leia from the evil clutch of Darth hrs 1 min "," Rating ":" 8.8 "," Votes ":" 397318 "," ID ":" tt0076759 "," Response ":" True "}
이러한 제목, 등급, 연도를 선택하여 내 개체에 저장하려면 어떻게 해야 합니까?
다음 행은 올바른 json을 반환합니다.
JObject jObject = JObject.Parse (json);
이제 원하는 데이터를 고르는 데 도움이 필요합니다.좋은 의견이라도 있나?
http://james.newtonking.com/pages/json-net.aspx 를 참조해 주세요.
string json = @"{
""Name"": ""Apple"",
""Expiry"": new Date(1230422400000),
""Price"": 3.99,
""Sizes"": [
""Small"",
""Medium"",
""Large""
]
}";
JObject o = JObject.Parse(json);
//This will be "Apple"
string name = (string)o["Name"];
에 관심이 있으시리라 믿습니다.JToken을 반환하는 항목[키] 컬렉션.
class TypeHere{
string Name {get;set;}
}
TypeHere object = JsonConvert.DeserializeObject< TypeHere >(jsonString)
// Ex. output
object.Name;
언급URL : https://stackoverflow.com/questions/9010021/get-value-from-json-with-json-net
반응형
'programing' 카테고리의 다른 글
| 플러그인에서 제목 태그를 변경하도록 wp_title을 설정하시겠습니까? (0) | 2023.04.05 |
|---|---|
| Oracle은 SQL Server의 테이블 변수와 동등합니까? (0) | 2023.04.05 |
| 사용자의 활성 및 비활성 Oracle 세션을 모두 종료하는 방법 (0) | 2023.04.05 |
| Contact Form 7의 이메일 송신을 금지하는 방법 (0) | 2023.04.05 |
| jquery/ajax를 사용하여 Div의 콘텐츠 새로 고침/재로드 (0) | 2023.04.05 |