【发布时间】:2014-01-12 17:36:25
【问题描述】:
{
"errorDesc": "",
"ownerId": 2096,
"departments": "Asset Protection,Backroom Flow,Bakery,Clinic,Dairy,Deli,Distribution (Communication),Facilities Management,Frozen,Guest Experience,Human Resources,Instocks,Meat,Optical,POG and Adjacencies,Pharmacy,Photo Lab,Portrait Studio,Presentation,Price Accuracy,Produce/Floral,Remodel,Reverse Logistics,Sales Floor: A&A,Sales Floor: Grocery,Sales Floor: Hardlines,Sales Floor: Health & Beauty,Sales Floor: Home,Signing and Fixtures,Starbucks,Store,Target Cafe",
"validUser": "Y",
"clientId": "TGT",
"displayPrio": "Y",
"allowSimpleProject": "Y",
"simpleProjectType": "SIM",
"reqDept": {
"STORE_AP": "Asset Protection",
"STORE_BF": "Backroom Flow",
"STORE_BAKERY": "Bakery",
"STORE_CLINIC": "Clinic",
"STORE_DAIRY": "Dairy",
"STORE_DELI": "Deli",
"STORE_DISTRIBUTI": "Distribution (Communication)",
"STORE_FM": "Facilities Management",
"STORE_FROZEN": "Frozen",
"STORE_GE": "Guest Experience",
"STORE_HR": "Human Resources",
"STORE_INSTOCKS": "Instocks",
"STORE_MEAT": "Meat",
"STORE_OPTICAL": "Optical",
"STORE_POG": "POG and Adjacencies",
"STORE_PHARM": "Pharmacy",
"STORE_PL": "Photo Lab",
"STORE_PS": "Portrait Studio",
"STORE_PRESENTATI": "Presentation",
"STORE_PA": "Price Accuracy",
"STORE_PROD": "Produce/Floral",
"STORE_REMODEL": "Remodel",
"STORE_RL": "Reverse Logistics",
"STORE_AA": "Sales Floor: A&A",
"STORE_GROC": "Sales Floor: Grocery",
"STORE_SFH": "Sales Floor: Hardlines",
"STORE_HB": "Sales Floor: Health & Beauty",
"STORE_HOME": "Sales Floor: Home",
"STORE_SIGNFIX": "Signing and Fixtures",
"STORE_STARBUCKS": "Starbucks",
"STORE": "Store",
"STORE_TC": "Target Cafe"
},
"viewOptions": null,
"sessionId": "c170be7b-81a3-4d95-a204-af72d166d28e",
"unitName": "MPLS-NICOLLET MALL",
"userId": "dderr-st",
"userName": "Dan Derr - Store",
"errorCd": "0",
"profiles": "STL/Store Team Lead,Specialist",
"view": "",
"unitId": "1375"
}
有人可以帮忙..如何为上面的 JSON 字符串创建 Object 类
这样我就可以做到这一点 - Gson gson = new Gson();
Register register_class = gson.fromJson(registration_response,Register.class);
register_list.add(register_class);
【问题讨论】:
-
您想要一个与该 JSON 匹配的类,以便您可以反序列化它?你试过什么?
-
我尝试创建类以匹配 JOSN。但在那个类中,我刚刚创建了有用的 getter 和 setter 对象。在这种方法上,我得到 Exception ::::: GSON 返回 Exception json 语法异常期望一个字符串,但在第 1 行第 15 列是 begin_object