我需要在 json 的单个键中存储许多值。例如
{
"number" : "1","2","3",
"alphabet" : "a", "b", "c"
}
像这样的东西。任何指针?
使用数组:
{
"number": ["1", "2", "3"],
"alphabet": ["a", "b", "c"]
}
您可以从它们在数组中的位置访问不同的值。计数从数组左侧的 0 开始。myJsonObject["number"][0] == 1
或myJsonObject["alphabet"][2] == 'c'
{
"number" : ["1","2","3"],
"alphabet" : ["a", "b", "c"]
}
{
"success": true,
"data": {
"BLR": {
"origin": "JAI",
"destination": "BLR",
"price": 127,
"transfers": 0,
"airline": "LB",
"flight_number": 655,
"departure_at": "2017-06-03T18:20:00Z",
"return_at": "2017-06-07T08:30:00Z",
"expires_at": "2017-03-05T08:40:31Z"
}
}
};