//代码
String taskParamsJson = dbBackAsynTask.getTaskParams();//json字符串 ObjectMapper objectMapper = new ObjectMapper(); //因为在非静态方法里面使用,new这个工具类 JsonNode paramsJson = objectMapper.readTree(taskParamsJson);//只获取异步任务的对应json里面的addSq04SupplierCodeList数据 JsonNode addSq04SupplierCodeListNode = paramsJson.get("addSq04SupplierCodeList"); if (addSq04SupplierCodeListNode != null && addSq04SupplierCodeListNode.isArray() && addSq04SupplierCodeListNode.size() > 0) { newSq04SupplierCodeList = objectMapper.readValue( addSq04SupplierCodeListNode.toString(), new TypeReference<List<SyncPartDataDTO.Sq04SupplierCode>>() {});//这个可以给对象,也可以是集合,看你需要数据的类型 }
//jar包 <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.13.5</version> </dependency>
//json格式 { "syncSource": "7", "leadPrjCode": "IVYTEST-483Z", "leadEvent": "Sourcing", "partSyncList": [ { "partNo": "01125A6051", "bomSyncList": [ { "prjCbomId": "001B8E934F59A5D1E06340981AAC85BE", "costFunctionCode": "A1AB", "gfunctionCode": "G22210---" } ] } ], "addSq04SupplierCodeList": [ { "sqSupplierPartMId": "001B8E936881A5D1E06340981AAC85BE", "prjCode": "IVYTEST-483Z", "event": "Sourcing", "supplierCode": "105X", "orderNo": 8 } ], "userId": "DE9F7EC1E7AF6E5BE053FB881AAC0B41", "followPrjCodeList": [ "Ivys-for BDS test" ] }
标签:483Z,addSq04SupplierCodeListNode,json,addSq04SupplierCodeList,获取,JSON,new,一部分,ob From: https://www.cnblogs.com/lboke/p/18234600