我写了这个JSON代码
public class TestClass {
public static void main(String[] args) {
String inputJson= "{" +"\"contexts\" : { "+ "{ " + "\"times\" : { " + "{ " + "\"end\":17, " + "\"begin\" : 9 " + "}" + "}," + "\"contextname\":\"OFFICE_HOURS\" " + "}," + "{ " + "\"days\": { " + "\"MON\", " + "\"TUE\", " + "\"WED\" , " + "\"THU\", " + "\"FRI\" " + "} , " + "\"contextname\" : \"WORKDAYS\" " + "}";
ObjectMapper mapper= new ObjectMapper();
mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
try {
MainParser mp= mapper.readValue(inputJson, MainParser.class);
System.out.println(mp.getContextname());
}
但我在控制台框中发现了此错误
org.codehaus.jackson.JsonParseException: Unexpected character ('{' (code 123)): was expecting double-quote to start field name
at [Source: java.io.StringReader@7cf10a6f; line: 1, column: 19]
我需要帮助
森林海
慕无忌1623718
相关分类