は、私は、JSON以下のように持っている: - 私は以下のように特定のオブジェクトに変換したい5.3
{
"_objectClassName": "Transfer_Sales_Order_Item",
"_idAttribute": "id_sales_order_item",
"_indexDirty": true,
"_data": [
{
"_attributes": {
"history_collection": "Transfer_Sales_Order_Item_Status_HistoryCollection",
"merchant": "Transfer_Sales_Order_Item_Merchant",
"shipment": "Transfer_Sales_Order_Item_Shipment",
"status": "Transfer_Sales_Order_Item_Status",
"fk_catalog_shipment_type": null,
"warehouse": "Transfer_Sales_Order_Address",
"brand": null,
"root_category": null,
"category": null,
"history_log_note": null,
"delivery_time": null,
"bundle_discount": null,
"fk_sku_bundle": null,
"is_freebie": null,
"shipping_charge": null,
"not_buyable": null,
"bundle_group": null,
"dispatch_time": null,
"info_collection": "Transfer_Sales_Order_Item_Additional_Info",
"trackinginfo_collection": "Transfer_Sales_Order_Shipment_Tracking_HistoryCollection",
"trakinginfo_summarized": null,
"status_history": null,
"text_collection": "Transfer_Sales_Order_Item_Custom_TextCollection",
"returninfo_summarized": null,
"refundinfo_summarized": null,
"shipping_special_service_info": "Transfer_Sales_Order_Item_Shipping_Special_Service",
"payback_credits_value": null,
"stock_version": null,
"fk_catalog_simple": null,
"item_attributes": "Transfer_Sales_Order_Item_Attributes"
},
"_defaultValues": {
"quantity": 1
},
"_data": {
"sku": "CA028SH10UTLINDFAS-697382",
"fk_catalog_simple": 697382,
"name": "Bronze Sandal",
"unit_price": 1095,
"catalog_tax_class": {
"_attributes": {
"tax_percent": null
},
"_defaultValues": [
],
"_data": {
"tax_percent": 0
}
},
"tax_percent": 0,
"original_unit_price": 1095,
"shipping_charge": 1,
"item_attributes": {
"_attributes": {
"is_surface": null,
"is_fragile": null,
"is_precious": null,
"seller_discount": 0,
"seller_price": 0,
"seller_sku": null
},
"_defaultValues": [
],
"_data": {
"is_surface": 0,
"is_fragile": 0,
"seller_sku": 1000211001,
"seller_price": 0
}
}
}
}
]
}
: -
Transfer_Sales_Order_ItemCollection Object
(
[_objectClassName:protected] => Transfer_Sales_Order_Item
[_idAttribute:protected] => id_sales_order_item
[_indexDirty:Transfer_AbstractCollection:private] => 1
[_data:protected] => Array
(
[0] => Transfer_Sales_Order_Item Object
(
[_attributes:protected] => Array
(
[history_collection] => Transfer_Sales_Order_Item_Status_HistoryCollection
[merchant] => Transfer_Sales_Order_Item_Merchant
[shipment] => Transfer_Sales_Order_Item_Shipment
[status] => Transfer_Sales_Order_Item_Status
[fk_catalog_shipment_type] =>
[warehouse] => Transfer_Sales_Order_Address
[brand] =>
[root_category] =>
[category] =>
[history_log_note] =>
[delivery_time] =>
[bundle_discount] =>
[fk_sku_bundle] =>
[is_freebie] =>
[shipping_charge] =>
[not_buyable] =>
[bundle_group] =>
[dispatch_time] =>
[info_collection] => Transfer_Sales_Order_Item_Additional_Info
[trackinginfo_collection] => Transfer_Sales_Order_Shipment_Tracking_HistoryCollection
[trakinginfo_summarized] =>
[status_history] =>
[text_collection] => Transfer_Sales_Order_Item_Custom_TextCollection
[returninfo_summarized] =>
[refundinfo_summarized] =>
[shipping_special_service_info] => Transfer_Sales_Order_Item_Shipping_Special_Service
[payback_credits_value] =>
[stock_version] =>
[fk_catalog_simple] =>
[item_attributes] => Transfer_Sales_Order_Item_Attributes
)
[_defaultValues:protected] => Array
(
[quantity] => 1
)
[_data:protected] => Array
(
[sku] => CA028SH10UTLINDFAS-697382
[fk_catalog_simple] => 697382
[name] => Bronze Sandal
[unit_price] => 1095
[catalog_tax_class] => Transfer_Catalog_Tax_Class Object
(
[_attributes:protected] => Array
(
[tax_percent] =>
)
[_defaultValues:protected] => Array
(
)
[_data:protected] => Array
(
[tax_percent] => 0
)
)
[tax_percent] => 0
[original_unit_price] => 1095
[shipping_charge] => 1
[item_attributes] => Transfer_Sales_Order_Item_Attributes Object
(
[_attributes:protected] => Array
(
[is_surface] =>
[is_fragile] =>
[is_precious] =>
[seller_discount] => 0
[seller_price] => 0
[seller_sku] =>
)
[_defaultValues:protected] => Array
(
)
[_data:protected] => Array
(
[is_surface] => 0
[is_fragile] => 0
[seller_sku] => 1000211001
[seller_price] => 0
)
)
)
)
)
)
私は上記のようなかなりの数のJsonスキーマを持っているので、誰かがこれを一般的な方法でどのように達成できるのか教えてもらえますか?
私はこのquestionを通過しましたが、回答はありませんでした。
私はこれもまたquestionも行っています。私の場合のように、そこにある回答は私には合いません。たとえば、属性自体がオブジェクトの場合があります。catalog_tax_class
はTransfer_Catalog_Tax_Class
です。
phpバージョン - 5.3.29。
は 'json_decode()'足りない良い結果であるか、その簡単な関数について聞いたことがありますか? – RiggsFolly
jsonを 'Transfer_Sales_Order_ItemCollection'のインスタンスに変換したいと思います。 'json_decode'を使ってこれをどうすれば実現できますか? – tuk
シンプルなことは、私が後にしていないことは十分に十分です。私はメッセージを受け取り、試みた回答を削除することができます – RiggsFolly