英文:
API Response JSON to Class Object in Java
问题
我从Azure API获取了一个JSON格式的服务响应,但我需要将它转换为Java类对象格式。请建议最简单的转换方法。
英文:
I am getting a service response from Azure API in JSON format, but I need to transform it into Java class object format. Please suggest the simplest way to transform
答案1
得分: 0
以下是翻译好的内容:
有一个网站,您可以在该网站上放置 JSON 响应并选择要创建类的语言。
这是最简单的转换方式 -
英文:
There is website on which you can put json response and select the language in which you want to create classes.
This is simplest way to transform -
答案2
得分: 0
你可以使用 com.fasterxml.jackson.databind.ObjectMapper
。
示例:
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
UserType user = mapper.readValue("your_Json", UserType.class);
英文:
You can use com.fasterxml.jackson.databind.ObjectMapper
Exemple :
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
UserType user= mapper.readValue("your_Json", UserType.class);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论