2011-03-23 3 views
0

어떻게 파싱 할 수 있습니까? Java에서 org.json을 사용하여 JSON 파일을 구문 분석 할 수 있습니까?

{ 
    "392bc124":  { 
      "ts":  { 
        "value":  "File content" 
      }, 
      "type":  "File content", 
      "sn":  "File content" 
    }, 
    "07dba83e":  { 
      "ts":  { 
        "value":  "File content" 
      }, 
      "type":  "File content", 
      "sn":  "File content" 
    }, 
    "a24faa33":  { 
      "ts":  { 
        "value":  "File content" 
      }, 
      "type":  "File content", 
      "sn":  "File content" 
    } 
} 

내가 알고 어떻게 작품 만

{ 
    "devices" : [ 
     { 
      "name" : "07dba83e" 
      "sn" : "c8abddf44e49986ff2cd03be6fd2b1fc", 
      "type" : "output", 
      "value" : "100" 
     }, 
     { 
      "name" : "392bc124" 
      "sn" : "644f2821b26a7d6c93720b26c5044b40", 
      "type" : "input", 
      "value" : "12" 
     }, 
     { 
      "name" : "a24faa33" 
      "sn" : "2893a640fd1b6102c84f035c42ee4257", 
      "type" : "dimmer", 
      "value" : "0" 
     } 
    ] 
} 

하나는 내가 어떻게 내가 이름을 모르는 경우 "392bc124"JSON 개체를 얻을 수에 대한 ("392bc124")? 두 번째 예제에서 나는 배열을 가지고 있지만 괜찮지 만, 모르겠다. 첫 번째 구문을 분석 할 수있는 방법이 있습니까?

+0

를 사용해야합니까? 그 결과는 무엇입니까? – Davidann

답변