2017-04-14 1 views
-2

다음 json formated 파일을 찾았습니다. 개장과 파싱이 가능합니까? 일반적으로 json에는 각 섹션에 대한 키와 값이 있지만 여기에는 하나의 배열에는 키가 있고 다른 배열에는 값이 있습니다. 그래서 그것을 파싱하는 방법?안드로이드 json Retrofit 라이브러리로 구문 분석

{ 
    "insertnewdatas": { 
    "columns": [ 
     "id", 
     "operatorName", 
     "latitude", 
     "longitude", 
     "location", 
     "address", 
     "currencies", 
     "exchange", 
     "exchangeLimits", 
     "workingDays", 
     "link", 
     "phone", 
     "email", 
     "dateTime", 
     "created_at", 
     "updated_at" 
    ], 
    "records": [ 
     [ 
     3, 
     "Coin Source", 
     "22.3475", 
     "91.8123", 
     "Chittagong", 
     "Oxygen , Chittagong", 
     "Cash", 
     "option2", 
     "$500/month", 
     "30", 
     "no link", 
     "017000000000", 
     "[email protected]", 
     "21-10-2017", 
     "2017-03-01 17:40:42", 
     "2017-03-01 17:40:42" 
     ], 
     [ 
     4, 
     "Coin Source", 
     "22.3475", 
     "91.8123", 
     "Chittagong", 
     "Oxygen , Chittagong", 
     "Cash", 
     "option2", 
     "$500/month", 
     "30", 
     "no link", 
     "017000000000", 
     "[email protected]", 
     "21-10-2017", 
     "2017-03-01 17:40:49", 
     "2017-03-01 17:40:49" 
     ], 
     [ 
     5, 
     "Bit Coin", 
     "22.3575", 
     "91.8323", 
     "Chittagong", 
     "Chittagong", 
     "both", 
     "option1", 
     "$500/month", 
     "30", 
     "no link", 
     "017000000000", 
     "[email protected]", 
     "21-10-2017", 
     "2017-03-01 17:43:34", 
     "2017-03-01 17:43:34" 
     ] 
    ] 
    } 
} 
+0

꽤 나쁜 형식입니다. 내가 그것을 변경하려고 시도하여 시작하는 것이 좋습니다 것이 – njzk2

답변

2

기본적으로 Retrofit은 자동화 된 JSON 구문 분석을 지원하지 않습니다. 하지만 당신은 GSON을 사용할 수 있습니다. https://github.com/google/gson

개조 및 GSON와 JSON을 구문 분석하는 방법을 짧은 튜토리얼 여기에 예를 들어 찾을 수 있습니다 http://www.pratikbutani.com/2016/05/android-tutorial-json-parsing-using-retrofit-part-1/

그러나 당신을 도울 것입니다 거기에 더 많은 튜토리얼이 있습니다.

+0

그 JSS는 개조와 파싱을 알고 있지만이 형식은 가능합니까? 그 형식에 대한 예가 있습니까? –

관련 문제