1
나는 안드로이드를 위해 그것을 구문 분석 rabl를 사용하여 JSON 형식으로 내 DB에서 데이터를 표시하고있어이 ... 내 JSON은 그래서 다음과 같습니다 레일 rabl의 JSON 형식
[
{
"bank":{
"central_office_address":"ololo",
"license":"12312312",
"location_id":3,
"name":"Pbank",
"tax_number":"12312312",
"year_of_foundation":1987
}
},
{
"bank":{
"central_office_address":"sdfsdf sdf",
"license":"321312",
"location_id":3,
"name":"Bbank",
"tax_number":"321321",
"year_of_foundation":1999
}
}
]
내가 같은 형식으로 내 JSON 필요 :
{
"contacts": [
{
"id": "c200",
"name": "Ravi Tamada",
"email": "[email protected]",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "male",
"phone": {
"mobile": "+91 0000000000",
"home": "00 000000",
"office": "00 000000"
}
},
{
"id": "c201",
"name": "Johnny Depp",
"email": "[email protected]",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "male",
"phone": {
"mobile": "+91 0000000000",
"home": "00 000000",
"office": "00 000000"
}
}
]
}
이러한 데이터는 일반적으로 .... 자바 구문 분석
내 rabl보기 :
object @banks
attributes :central_office_address, :license, :location_id, :name, :tax_number, :year_of_foundation
두 번째 예제와 일치하도록 출력을 변경하려면 어떻게해야합니까?
collection @banks, :root => "bank", :object_root => false
attributes :central_office_address, :license, :location_id, :name, :tax_number, :year_of_foundation
어쩌면 그것이 나쁜 생각 :
롤백 편집 주석 : 원하는 형식과 일치시키기 위해 "은행"이 아니라 "은행"이어야합니다. –