2013-09-16 1 views
3

JSON에서 여러 값을 표시하려고하지만 할 수 없습니다. 문제점에 대한 해결책을 찾으려고했지만 실패했습니다. 그러므로 누군가가 나를 도와 주겠다는 의문과 희망을 묻습니다.SimpleJSON으로 json의 데이터를 표시하는 방법은 무엇입니까?

{ 
projects: [ 
    { 
    id: "1", 
    name: "sssssdd" 
    }, 
    { 
    id: "2", 
    name: "ccccc" 
    }, 
    { 
    id: "3", 
    name: "dasdasd" 
    } 
] 
} 

그리고이 내 코드 :

using UnityEngine; 
using System.Collections; 
using SimpleJSON; 

public class simpleRequest : MonoBehaviour { 

    IEnumerator SendRequest() 
    { 
     WWW request = new WWW("http://localhost:9999/post/results.json"); 


     yield return request; 

     if (request.error == null || request.error == "") 
     { 

      var N = JSON.Parse(request.text); 

      Debug.Log(N["projects"][0]["name"]); 

     } 
     else 
     { 
      Debug.Log("WWW error: " + request.error); 
     } 
    } 

    void Start() 
    { 
     StartCoroutine(SendRequest()); 
    } 
} 

실례하시기 바랍니다

이 내 JSON 데이터입니다! 나는 영어가 능숙하지 않다.

답변

3

다른 데이터 형식에는 Debug.Log(N["projects"][0]["name"].Value); 또는 N["projects"][0]["name"].AsInt, N["projects"][0]["name"].AsFloat 등을 사용해야합니다.

관련 문제