json数据转化出错.
-------------------出错的代码--------------------------------
ObjectMapper objectMapper = new ObjectMapper();
//String ss = "{\"where\":\" if (\\\"\'浙江省\'\\\" = \\\"\'\'\\\", 1=0, cus.state in (\'浙江省\')) or if (\\\"\'\'\\\"=\\\"\'\'\\\", 1=0, cus.city in (\'\')) or if (\\\"\'\'\\\"=\\\"\'\'\\\", 1=0, cus.district in (\'\')) \"}";
String ss = "{\"where\":\" if (\"'浙江省'\" = \"''\", 1=0, cus.state in ('浙江省')) or if (\"''\"=\"''\", 1=0, cus.city in ('')) or if (\"''\"=\"''\", 1=0, cus.district in ('')) \"}";
objectMapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES , true);
Map<String,Object> sql_map = objectMapper.readValue(ss,HashMap.class);
System.out.println(sql_map.get("where"));
Exception in thread "main" org.codehaus.jackson.JsonParseException: Unexpected character (''' (code 39)): was expecting comma to separate OBJECT entries
at [Source: java.io.StringReader@b76fa; line: 1, column: 18]
at org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1432)
at org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:385)
at org.codehaus.jackson.impl.JsonParserMinimalBase._reportUnexpectedChar(JsonParserMinimalBase.java:306)
at org.codehaus.jackson.impl.ReaderBasedParser.nextToken(ReaderBasedParser.java:400)
at org.codehaus.jackson.map.deser.std.MapDeserializer._readAndBind(MapDeserializer.java:304)
at org.codehaus.jackson.map.deser.std.MapDeserializer.deserialize(MapDeserializer.java:249)
at org.codehaus.jackson.map.deser.std.MapDeserializer.deserialize(MapDeserializer.java:33)
at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2723)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1854)
at com.hupun.crm.business.custom.impl.TestJson.main(TestJson.java:53)
-------------------------------修改后----------------------
ObjectMapper objectMapper = new ObjectMapper();
String ss = "{\"where\":\" if (\\\"\'浙江省\'\\\" = \\\"\'\'\\\", 1=0, cus.state in (\'浙江省\')) or if (\\\"\'\'\\\"=\\\"\'\'\\\", 1=0, cus.city in (\'\')) or if (\\\"\'\'\\\"=\\\"\'\'\\\", 1=0, cus.district in (\'\')) \"}";
//String ss = "{\"where\":\" if (\"'浙江省'\" = \"''\", 1=0, cus.state in ('浙江省')) or if (\"''\"=\"''\", 1=0, cus.city in ('')) or if (\"''\"=\"''\", 1=0, cus.district in ('')) \"}";
objectMapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES , true);
Map<String,Object> sql_map = objectMapper.readValue(ss,HashMap.class);
System.out.println(sql_map.get("where"));
分享到:
相关推荐
在学习python语言中用json库解析网络数据时,我遇到了两个编译错误:json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes:和json.decoder.JSONDecodeError: Expecting value:。...
主要介绍了python中报错"json.decoder.JSONDecodeError: Expecting value:"的解决方法 ,需要的朋友可以参考下
如下sql,JSON_OBJECT函数中存在CAST函数,随后报出ParseException问题! SELECT JSON_ARRAYAGG(obj) FROM (SELECT trt.relevance_id,JSON_OBJECT('id',CAST(trt.id AS CHAR),'taskName',trt.task_name,'openStatus'...
用stanfordCoreNLP进行中文分词时出现json编码错误(csdn)————程序
主要给大家介绍了关于Python解析json报错:ValueError: Expecting property name enclosed in double quotes: line 1 column 2(char 1)的解决方法,文中介绍的非常详细,需要的朋友们可以参考借鉴,下面来一起看看...
今天在处理 JSON 数据的时候遇到了一个意想不到的问题,不过也算是个小问题吧,记录一下解决方案,同时提醒自己下次不要犯同样的错误了。 目录 一、json (一)json.loads (二)json.dumps 二、问题 三、解决方法 ...
blog posts might look like, but as I was about to tease it apart into separate files I stopped myself. Why not turn it into a book instead? I approached some friends to see if anyone was interested in...
Starting with a detailed analysis of object-oriented technique and design, you will use the Python programming language to clearly grasp key concepts from the object-oriented paradigm. This module ...
raise JSONDecodeError(“Expecting value”, s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)报错! 在找到某度文库文档的js文件链接后想用json.loads()进行解析...
可图形化的 JSON JS 这是的 JavaScript 实现。 安装 运行以下命令安装库: npm install graphablejson 有一个示例 API https://graphablejsonapi.glitch.me/orders/1000 。 您还可以查看目录以了解如何使用该库。...
由于项目需要,需要在线预览文档,所以就想转换为... 此项目为maven项目,引入的包可能需要一些时间; maven项目转换为eclipse项目命令是:mvn eclipse:eclipse,然后导入到eclipse; jar引入完成后,绝对100%能运行;
"A 'must-have' book for anyone expecting to do research and/or applications in categorical data analysis." –Statistics in Medicine on Categorical Data Analysis, First Edition The use of statistical ...
不然回报错:“syntax error: unexpected newline, expecting comma or } ”。运行main.go之前,先进行go build,这样子才会去执行init函数注册到BalanceMgr里面。不然不会调用init函数。 package balance import
It doesn't just give you instructions, expecting you to follow them. Instead, with a hands-on approach, it demonstrates what Ionic is capable of through a series of practical projects that you can ...
您可能感兴趣的文章:python 对字典按照value进行排序的方法Python实现字典按key或者value进行排序操作示例【sorted】python中报错”json.decoder.JSONDecodeError: Expecting value:”的解决对python中字典keys,...
包括:libsigar-aarch64-linux.so、libsigar-amd64-linux.so、libsigar-x86-linux.so、sigar-amd64-winnt.dll、sigar-x86-winnt.dll、sigar-x86-winnt.lib
Traditional network television programming has always followed the same script: executives approve a pilot, order a trial number of episodes, and broadcast them, expecting viewers to watch a given ...
LSIP200245968 (DFCT) In EFICLI not able to flash latest firmware to controller without using -nosigchk -noverchk option. LSIP200233079 (DFCT) Redesign battery changes LSIP200232955 (DFCT) Porting ...
Ruby Quick Syntax Reference.pdf Ruby速查手册,Ruby这语言听起来就很酷! 英文PDF版本,欢迎下载!