Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当 json-rpc 传入的数组中有回车时,Json格式化错误 #59

Closed
chenzhitong opened this issue Aug 23, 2017 · 1 comment
Closed
Labels
bug Used to tag confirmed bugs

Comments

@chenzhitong
Copy link
Member

当 json-rpc 请求的数组中有回车或换行时,服务器会返回错误(-32700 Parse error)。

{
  "jsonrpc": "2.0",
  "method": "sendmany",
  "params": [[
  	{"asset": "025d82f7b00a9ff1cfe709abe3c4741a105d067178e645bc3ebad9bc79af47d4","value": 1,"address": "AbRTHXb9zqdqn5sVh4EYpQHGZ536FgwCx2"},{"asset": "025d82f7b00a9ff1cfe709abe3c4741a105d067178e645bc3ebad9bc79af47d4","value": 1,"address": "AbRTHXb9zqdqn5sVh4EYpQHGZ536FgwCx2"}]],
  "id": 1
}

将数组中的回车删掉,服务器会返回正确结果

{
  "jsonrpc": "2.0",
  "method": "sendmany",
  "params": [[{"asset": "025d82f7b00a9ff1cfe709abe3c4741a105d067178e645bc3ebad9bc79af47d4","value": 1,"address": "AbRTHXb9zqdqn5sVh4EYpQHGZ536FgwCx2"},{"asset": "025d82f7b00a9ff1cfe709abe3c4741a105d067178e645bc3ebad9bc79af47d4","value": 1,"address": "AbRTHXb9zqdqn5sVh4EYpQHGZ536FgwCx2"}]],
  "id": 1
}

估计是 JSON 解析的时候出错的,当用 Newtonsoft Json.NET 解析时不会出错。

更简单的测试用例:

{
  "jsonrpc": "2.0",
  "method": "getblockcount",
  "params": [
  	],
  "id": 1
}

JSON 解析错误

{
  "jsonrpc": "2.0",
  "method": "getblockcount",
  "params": [],
  "id": 1
}

JSON 解析正确

@erikzhang
Copy link
Member

It seems if you put a "\t" character into the JSON string, you will get this error.

@erikzhang erikzhang added the bug Used to tag confirmed bugs label Aug 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to tag confirmed bugs
Projects
None yet
Development

No branches or pull requests

2 participants