如何在查询字符串中具有此结构?
"properties": {
"list": [
{
"label": "bye",
"value": "world"
},
{
"label": "hello",
"value": "mars"
}
]
}
我已经尝试过properties[][list][label]=bye&properties[][list][value]=world&properties[0][label]=hello&properties[0][value]=mars
,也曾经尝试过properties[][list][label]=bye&properties[][list][value]=world&properties[][list][label]=hello&properties[][list][value]=mars
,但都没有用。我用php构建它们http_build_query
。
我需要在查询字符串中具有此结构,因为我必须将数据以及其他一些内容通过POST发送到PHP站点。
我在查询字符串中看到两个错误:
properties
是一个对象,因此无需使用[]
添加元素。list
是一个数组,因此必须在查询字符串中使用数字索引。正确的查询字符串是:
?properties[list][0][label]=bye
&properties[list][0][value]=world
&properties[list][1][label]=hello
&properties[list][1][value]=mars
(多行以提高可读性)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句