📜  jackson 从字符串创建对象节点 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:34.993000             🧑  作者: Mango

代码示例1
@Testpublic 
void givenTheJsonNode_whenRetrievingDataFromId_thenCorrect()   throws JsonParseException, IOException {
  String jsonString = "{"k1":"v1","k2":"v2"}";    
  ObjectMapper mapper = new ObjectMapper();
  
  JsonNode actualObj = mapper.readTree(jsonString);  
  JsonNode jsonNode1 = actualObj.get("k1");
  
  assertThat(jsonNode1.textValue(), equalTo("v1"));
}