Parsing JSON to POJO using GSON

后端 未结 2 469
有刺的猬
有刺的猬 2020-12-21 15:22

My JSON looks like follow :

\"message_defaults\": {
      \"LabResultsRequestDefaultMessage\": {
        \"MsgTypeId\": 8,
        \"StaffId\":          


        
2条回答
  •  孤城傲影
    2020-12-21 15:40

    You can do the following without changing your json structure.

    Type mapType = new TypeToken>() {}.getType();
    Map messagesMap = gson.fromJson(json, mapType);
    List messages = new ArrayList(messagesMap.values());
    

提交回复
热议问题