任何人都可以帮助我将下面的 JSON 转换为 java 对象(列表),而无需 java bean。我是 JSON 的新手
Could anyone help me to convert the below JSON to java object (List), without a java bean. Am new to JSON
[
{
"id": "1234",
"price": 1000,
"categories": [
"Fashion/Shirt"
],
"category_id": [
"1234564"
],
"gender": "Male",
"brand": "Wonder",
"fashion_composition": [
{
"material": "silk",
"percentage": 78
},
{
"material": "Cotton",
"percentage": 22
}
],
"fashion_season": {
"season": "continuity",
"year_season": 2014
},
"fashion_size": {
"size_type": "US",
"size_description_1": "size",
"size_1_manufacturer": "90",
"size_description_2": "top",
"size_2_manufacturer": "C",
"size_1": [
"90"
],
"size_2": [
"C"
]
}
},
{
"id": "5678",
"price": 1000,
"categories": [
"Fashion/Skirt"
],
"category_id": [
"1234564"
],
"gender": "Female",
"brand": "Wonder",
"fashion_composition": [
{
"material": "silk",
"percentage": 78
},
{
"material": "Cotton",
"percentage": 22
}
],
"fashion_season": {
"season": "continuity",
"year_season": 2014
},
"fashion_size": {
"size_type": "US",
"size_description_1": "size",
"size_1_manufacturer": "90",
"size_description_2": "top",
"size_2_manufacturer": "C",
"size_1": [
"90"
],
"size_2": [
"C"
]
}
}
]
我正在使用 gson-2.2。4.jar
我猜你的意思是不为 GSON 反序列化编写自己的 bean。 GSON 通过某些 JSON 类型提供支持,您可以使用这些类型:
Gson gson = new Gson();
final JsonArray jsonElements = gson.fromJson(JSON, JsonArray.class);
[
{
"id": "1234",
"price": 1000,
"categories": [
"Fashion/Shirt"
],
"category_id": [
"1234564"
],
"gender": "Male",
"brand": "Wonder",
"fashion_composition": [
{
"material": "silk",
"percentage": 78
},
{
"material": "Cotton",
"percentage": 22
}
],
"fashion_season": {
"season": "continuity",
"year_season": 2014
},
"fashion_size": {
"size_type": "US",
"size_description_1": "size",
"size_1_manufacturer": "90",
"size_description_2": "top",
"size_2_manufacturer": "C",
"size_1": [
"90"
],
"size_2": [
"C"
]
}
},
{
"id": "5678",
"price": 1000,
"categories": [
"Fashion/Skirt"
],
"category_id": [
"1234564"
],
"gender": "Female",
"brand": "Wonder",
"fashion_composition": [
{
"material": "silk",
"percentage": 78
},
{
"material": "Cotton",
"percentage": 22
}
],
"fashion_season": {
"season": "continuity",
"year_season": 2014
},
"fashion_size": {
"size_type": "US",
"size_description_1": "size",
"size_1_manufacturer": "90",
"size_description_2": "top",
"size_2_manufacturer": "C",
"size_1": [
"90"
],
"size_2": [
"C"
]
}
}
]
我正在使用 gson-2.2。4.jar
我猜你的意思是不为 GSON 反序列化编写自己的 bean。 GSON 通过某些 JSON 类型提供支持,您可以使用这些类型:
Gson gson = new Gson();
final JsonArray jsonElements = gson.fromJson(JSON, JsonArray.class);