api에 쿼리를 작성한 후 json 응답을받습니다.C#에서 JSON 응답 구문 분석
내가 위에서 JSON 결과에 두 가지 일을 할 필요가{
"results": [
{
"alternatives": [
{
"confidence": 0.965,
"transcript": "how do I raise the self esteem of a child in his academic achievement at the same time "
}
],
"final": true
},
{
"alternatives": [
{
"confidence": 0.919,
"transcript": "it's not me out of ten years of pseudo teaching and helped me realize "
}
],
"final": true
},
{
"alternatives": [
{
"confidence": 0.687,
"transcript": "is so powerful that it can turn bad morals the good you can turn awful practice and the powerful once they can teams men and transform them into angel "
}
],
"final": true
},
{
"alternatives": [
{
"confidence": 0.278,
"transcript": "you know if not on purpose Arteaga Williams who got in my mother "
}
],
"final": true
},
{
"alternatives": [
{
"confidence": 0.621,
"transcript": "for what pink you very much "
}
],
"final": true
}
],
"result_index": 0
}
(나는 문자열 *로 유지) :
json으로 같은 것입니다
- 성적 증명서 부분 (들)를 가져옵니다 json 응답.
해당 문자열을 처리하십시오.
- 새로운 소식입니다. 문자열로 변환하는 것은 직렬화라고 불립니다. 왜 deserialization이 도움이 될까요?
문자열로 변환 :
var reader = new StreamReader(response.GetResponseStream());
responseFromServer = reader.ReadToEnd();
어떻게 이것을 달성하기 위해 : 내가 사용을 했습니까?
역 직렬화의 필요는 없습니다. 그러나 당신의 삶을 편하게 만듭니다. o) –
JSON을 역 직렬화하면 .NET 객체로 역 직렬화됩니다. 그런 다음 문자열 구문 분석을 수행하는 대신 해당 객체의 속성에 액세스 할 수 있습니다. deserialization을 돕기 위해 Newtonsoft JSON.NET과 같은 라이브러리를 사용하십시오. – wablab