我有以下代码:
public void testJackson() throws IOException { ObjectMapper mapper = new ObjectMapper(); File from = new File("albumnList.txt"); TypeReference<HashMap<String,Object>> typeRef = new TypeReference<HashMap<String,Object>>() {}; HashMap<String,Object> o = mapper.readValue(from, typeRef); System.out.println("Got " + o); } 它是从文件读取的,但
mapper.readValue()也将接受,
InputStream并且你可以
InputStream使用以下命令从字符串中获取:
new ByteArrayInputStream(astring.getBytes("UTF-8")); 


