如何为动态密钥解析此类JSON数据

时间:2012-02-14 09:07:11

标签: android json

{"Freedom Plan 4900":
    {
    "sale_price1":["$10.00","$20.00","$25.00","$50.00","$100.00"],
    "loc_rate1":["India (2.0¢ per min)"],
    "net_minutes1":["500","1,000","1,250","2,500","5,000"],
    "loc_rate":["India - Mobile (1.5¢ per min)"],
    "net_minutes":["666","1,333","1,666","3,433","6,866"]
    },

"Super Offer Plan":
    {
    "sale_price1":["$10.00"],
    "loc_rate1":["India (1.5¢ per min)"],
    "net_minutes1":["667"],
    "loc_rate":["India - Mobile (1.0¢ per min)"],
    "net_minutes":["1,000"]
    }

}

我想解析这个json字符串

1 个答案:

答案 0 :(得分:1)

我会使用类似GSON的东西:

http://sites.google.com/site/gson/gson-user-guide

创建用于保存数据的类(例如PhonePlan等)并让GSON解析JSON字符串。

PhonePlan plan = gson.fromJson(json, PhonePlan.class);