Branch: refs/heads/master
Home: https://github.com/conformal/btcjson
Commit: 016e69cd510bf9b1c7dbd671152959b13fd8adcd
https://github.com/conformal/btcjson/commit/016e69cd510bf9b1c7dbd671152959b13fd8adcd
Author: Dave Collins <[email protected]>
Date: 2014-04-10 (Thu, 10 Apr 2014)
Changed paths:
M jsoncmd.go
M test_coverage.txt
Log Message:
-----------
Convert RawCmd to use raw messages for params.
This commit modifies the RawCmd type to use a slice of json.RawMessages so
that unmarshalling each individual parameter can be deferred to the
handler for the command.
This is superior to the old method of using a []interface{} because it
means that each parameter is now unmarshalled into the expected concrete
type directly instead of whatever it happens to be in the JSON. Due to
this, the old behavior where every number was unmarshlled as a float64 and
converted to the appropriate final type, which could lead to odd behavior
when going through marshal/unmarshal cycles, has been eliminated. This
change also means each individual parameter can now be full blown structs
(JSON objects) that marshal and unmarshal themselves which greatly
simplifies complex parameters and removes the need for additional and
error prone code.
This commit contains a lot of changes because every command needed its
MarshalJSON and UnmarshalJSON methods updated to support the new
mechanism. As a part of changing these functions, a new common creation
function for the the RawCmd struct was added to avoid the previous
duplication of the common fields. Also, rather than repeating the method
string in each MarshJSON functon, it makes use of cmd.Method().
Finally, some of the error messages were incorrect and have been corrected
as well as made consistent.
ok @jcvernaleo, @jrick, @owainga