1
SoloCompany 2016-11-19 02:58:26 +08:00
echo '{, "code":233}' | jsondecode
+ERR: Invalid Json content: Missing value at 1 [character 2 line 1] 试了下自己写的,果然兼容不了😭 |
2
onlyice 2016-11-19 08:27:45 +08:00 via Android
@SoloCompany 666 ,自己写的 JSON 解析器吗
|
3
lrh3321 2016-11-19 09:04:12 +08:00
这个 JSON 是字符串拼接出来的吧
|
5
Ouyangan 2016-11-19 12:21:57 +08:00
看到有点尴尬
|
6
wyntergreg 2016-11-19 14:53:37 +08:00
后端手动拼?好奇后端用的什么语言?
|
7
mindcat 2016-11-19 15:24:41 +08:00
╭─mindcat@mindcat-linux-pc ~/workspace/tools/人民币大写 ‹ master*›
╰─➤ echo '{, "code":233}' | js-beautify 127 ↵ {, "code": 233 }% ╭─mindcat@mindcat-linux-pc ~/workspace/tools/人民币大写 ‹ master*› ╰─➤ python2 Python 2.7.12 (default, Jun 28 2016, 08:31:05) [GCC 6.1.1 20160602] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import simplejson as json >>> json.loads('{, "code":233}') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/site-packages/simplejson/__init__.py", line 516, in loads return _default_decoder.decode(s) File "/usr/lib/python2.7/site-packages/simplejson/decoder.py", line 374, in decode obj, end = self.raw_decode(s) File "/usr/lib/python2.7/site-packages/simplejson/decoder.py", line 404, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) simplejson.scanner.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1) >>> |
8
ayanamist 2016-11-19 16:07:50 +08:00
@wyntergreg 腾讯大部分都是 C 艹的,手动拼 json 在 C 艹圈子里实在是太常见了,理由最常见的就是性能啦:我不需要返回那么复杂的格式,就这样手动拼,快多少多少倍 blahblah
|
10
zonyitoo 2016-11-20 01:25:36 +08:00
真的吗?楼主仔细说说?要是真的我去吐槽一下?
|
11
sagaxu OP 周末撸了个允许多余逗号的 parser ,暂时先凑合着用了
|
12
asdf33 2016-11-20 13:36:55 +08:00
果断替换掉 /{\n?\s*,/ -> {
|
13
hellocity 2016-11-23 12:07:05 +08:00
楼主你好,我是腾讯广点通的,想了解下详细情况,方便加我 QQ 么? 151020150 ,谢谢~
|