我想将以下输入JSON转换为输出JSON格式
输入JSON:
$request->has('name_of_checkbox')
输出JSON:
[
{
"orderNumber": "201904-000000001",
"items": [
{
"itemPrice": 40000,
"itemQuantity": 11,
"item": {
"external_id": "IPHONE"
}
},
{
"itemPrice": 25000,
"itemQuantity": 22,
"item": {
"external_id": "ONEPLUS"
}
},
{
"itemPrice": 35000,
"itemQuantity": 33,
"item": {
"external_id": "SAMSUNGS10"
}
}
]
}
]
我尝试遵循不起作用的规范...可以有人指导我有关规范的信息,如果嵌套数组和对象甚至更深入地介绍了如何转换,则应尽可能解释每个步骤
我使用过的规格:
[{
"orderNumber" : "201904-000000001",
"items" : [ {
"itemQuantity" : 11,
"external" : "IPHONE"
} ]
},
{
"orderNumber" : "201904-000000001",
"items" : [ {
"itemQuantity" : 22,
"external" : "ONEPLUS"
} ]
},
{
"orderNumber" : "201904-000000001",
"items" : [ {
"itemQuantity" : 33,
"external" : "SAMSUNGS10"
} ]
}]
答案 0 :(得分:0)
谢谢大家,在尝试不同的组合后,遵循规范确实为我工作。如果有人遇到这个问题,请给我解释下一次不尝试组合的答案
(rand.Next(0, 100) < 99