我试图对一个对象进行json_编码,但我希望外部 Package 器是一个数组,而不是一个对象。
我试过了 json_encode($myObject, JSON_OBJECT_AS_ARRAY)
但我的最终结果总是
{
"SALDOC": [
{
"SERIES": null,
"TRDR": null,
"PAYMENT": "2",
"SHIPMENT": "",
"TRNDATE": "2019-03-11 07:57:38",
"REMARKS": null,
"DISC1VAL": "0.0000",
"SALESMAN": null,
"SHIPKIND": null,
"CCCCLCOURIERWEIGHT": "1.0000"
}
],
"ITELINES": [
{
"LINENUM": null,
"VAT": null,
"MTRUNIT4": null,
"MTRCATEGORY": null,
"MTRL": null,
"QTY1": "1.0000",
"PRICE": "15.0000"
}
],
"MTRDOC": [
{
"SHPZIP": "test",
"SHPCITY": "teset",
"SHIPPINGADDR": "test",
"SHPDISTRICT": 100
}
],
"SRVLINES": [],
"EXPANAL": []
}
如何使外 Package 成为数组[]而不是对象{}?
1条答案
按热度按时间yr9zkbsy1#
如果我猜你想把一个对象转换成数组,对吗?因此,您可以使用:
$get\u array=json\u decode(json\u encode($myobject),true);返回$get_数组;