type of ID is changed
Closed this issue · 10 comments
in this example the ID is changed from a int to a floating point value
⋊> ~ curl --data '{"jsonrpc":"2.0","id":43,"method":"account_list","params":[]}' -H 'content-type:application/json' http://127.0.0.1:5000/ 17:19:35
{"jsonrpc":"2.0","result":"[{\"address\":\"afb2f771f58513609765698f65d3f2f0224a956f\",\"type\":\"account\",\"url\":\"keystore://foo\"}]","id":43.0}
I think this is an issue of Gson, the JSON library used. I don't think they distinguish between integers and floats.
Is it an actual problem?
Looking into this a little bit, I don't think I can do much about it on my side. Since ID can be an Any, Gson will treat the integer as a floating point number.
hm - actually for me it is not yet a problem. Would still consider this as a bug and think someone in the future will stumble uppon this - I think this should be kept open as a bug.
Is there no way to not parse this value at all? Just return as given ;-)
The JSON returned back to the user is generated from a Map<String, Any>. Anything else will be difficult and would require major refactoring.
If it really is a problem, the user should use a string as the ID. Or a floating-point number.
If it really is a problem, the user should use a string as the ID. Or a floating-point number.
The user might not always be control over both ends
Thanks for addressing this issue!
just wondering:
val id = json.substringAfter("\"id\":").split(",".toRegex())[0].trim()
this would only work when the id is not the last element - right? Because otherwise there would be no comma following..
right..
PS: happy to review PR's for this project - so things like this do not end up on master. So if you want this - open PRs with changes and tag me
Not sure if I'm gonna address it any further right now. At least it's better than it was.
PS: happy to review PR's for this project - so things like this do not end up on master. So if you want this - open PRs with changes and tag me
Will keep that in mind. Thanks