将多个值存储在 json 中的单个键中 [英] Store multiple values in single key in json
本文介绍了将多个值存储在 json 中的单个键中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在 json 的单个键中存储许多值.例如
I need to store many values in single key of json. e.g.
{
"number" : "1","2","3",
"alphabet" : "a", "b", "c"
}
类似的东西.有什么指点吗?
Something like this. Any pointers?
推荐答案
使用数组:
{
"number": ["1", "2", "3"],
"alphabet": ["a", "b", "c"]
}
您可以从数组中的位置访问不同的值.从数组左侧的 0 处开始计数.myJsonObject["number"][0] == 1
或 myJsonObject["alphabet"][2] == 'c'
You can the access the different values from their position in the array. Counting starts at left of array at 0. myJsonObject["number"][0] == 1
or myJsonObject["alphabet"][2] == 'c'
这篇关于将多个值存储在 json 中的单个键中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文