0

これをGSONで解析するにはどうすればよいですか? これは数字の「1」と「2」で始まっているからです。entity_id で始まるオブジェクトのオブジェクトを作成しました。これは、外部の json (「1」を含む) を削除したときに機能します。

しかし、私はこの一連のコード全体を 1 つで解析したいと考えています。「1」と「2」も解析するにはどうすればよいですか?String id と List innerobjects のようなものですか?

{
  "1": {
    "entity_id": "1",
    "status": "complete",
    "coupon_code": null,
    "shipping_description": "Flat Rate - Fixed",
    "customer_id": null,
    "base_discount_amount": "0.0000",
    "base_grand_total": "3422.3800",
    "base_shipping_amount": "90.0000",
    "base_shipping_tax_amount": "0.0000",
    "base_subtotal": "3332.3800",
    "base_tax_amount": "0.0000",
    "base_total_paid": "3422.3800",
    "base_total_refunded": null,
    "discount_amount": "0.0000",
    "grand_total": "3422.3700",
    "shipping_amount": "90.0000",
    "shipping_tax_amount": "0.0000",
    "store_to_order_rate": "1.0000",
    "subtotal": "3332.3700",
    "tax_amount": "0.0000",
    "total_paid": "3422.3700",
    "total_refunded": null,
    "base_shipping_discount_amount": "0.0000",
    "base_subtotal_incl_tax": "3332.3800",
    "base_total_due": "0.0000",
    "shipping_discount_amount": "0.0000",
    "subtotal_incl_tax": "3332.3700",
    "total_due": "0.0000",
    "increment_id": "100000001",
    "base_currency_code": "EUR",
    "discount_description": null,
    "remote_ip": "472.15.1.83",
    "store_currency_code": "EUR",
    "store_name": "Main Website\nMain Website Store\nDefault Store View",
    "created_at": "2012-08-10 09:37:17",
    "shipping_incl_tax": "90.0000",
    "payment_method": "checkmo",
    "gift_message_from": null,
    "gift_message_to": null,
    "gift_message_body": null,
    "tax_name": null,
    "tax_rate": null,
  },
  "2": {
    "entity_id": "2",
    "status": "pending",
    "coupon_code": null,
    "shipping_description": "Flat Rate - Fixed",
    "customer_id": null,
    "base_discount_amount": "0.0000",
    "base_grand_total": "1140.7900",
    "base_shipping_amount": "30.0000",
    "base_shipping_tax_amount": "0.0000",
    "base_subtotal": "1110.7900",
    "base_tax_amount": "0.0000",
    "base_total_paid": null,
    "base_total_refunded": null,
    "discount_amount": "0.0000",
    "grand_total": "1140.7900",
    "shipping_amount": "30.0000",
    "shipping_tax_amount": "0.0000",
    "store_to_order_rate": "1.0000",
    "subtotal": "1110.7900",
    "tax_amount": "0.0000",
    "total_paid": null,
    "total_refunded": null,
    "base_shipping_discount_amount": "0.0000",
    "base_subtotal_incl_tax": "1110.7900",
    "base_total_due": null,
    "shipping_discount_amount": "0.0000",
    "subtotal_incl_tax": "1110.7900",
    "total_due": null,
    "increment_id": "100000002",
    "base_currency_code": "EUR",
    "discount_description": null,
    "remote_ip": "182.11.7.52",
    "store_currency_code": "EUR",
    "store_name": "Main Website\nMain Website Store\nDefault Store View",
    "created_at": "2012-08-15 15:19:35",
    "shipping_incl_tax": "30.0000",
    "payment_method": "checkmo",
    "gift_message_from": null,
    "gift_message_to": null,
    "gift_message_body": null,
    "tax_name": null,
    "tax_rate": null,
  }
}
4

2 に答える 2

1

Map奇数"1", "2", ...オブジェクトには a を使用します。

Map<String, Order> map = gson.fromJson(json, Map.class);
于 2013-02-05T09:54:10.967 に答える