Nano-node: Replace JSON library

Created on 27 Mar 2019  路  4Comments  路  Source: nanocurrency/nano-node

The current use of Boost ptree in RPC is problematic for several reasons:

  • The output is not standard JSON

    • Empty objects and arrays are replaced with strings

    • Bool values are quoted

    • Numbers are quoted. However, arbitrary precision numbers (such as balances) should still be quoted. This is fairly common practice because several JSON parsers otherwise fail or give the wrong result.

  • Slow and memory hungry
  • No streaming/sax support. We may want to employ this in the future for more efficient handling of large requests/responses.

Challenges/notes:

  • Just replacing the library would be a breaking change. The approach will be to make the JSON backend configurable. We can deprecate Boost ptree, but keep it default for a while.
  • It's a large change, as it touches all RPC actions and block-json serializations.

    • Step 1 is to make an internal library, e.g a common interface which can have multiple implementations.



      • Implement Boost ptree backend


      • Implement RapidJSON backend (RapidJSON will likely be a git submodule)



    • Step 2 is to replace all use of Boost ptree with the internal library.


This replaces a few related issues.

Most helpful comment

@kolya182 out of curiosity, would your Go client deal with both history being an empty array [] and history not being present at all in the JSON?

Empty array is expected for address with 0 transactions, instead history returns different type. Expecting to have history property no matter amount of transactions would be ideal.

All 4 comments

@kolya182 out of curiosity, would your Go client deal with both history being an empty array [] and history not being present at all in the JSON?

@kolya182 out of curiosity, would your Go client deal with both history being an empty array [] and history not being present at all in the JSON?

Empty array is expected for address with 0 transactions, instead history returns different type. Expecting to have history property no matter amount of transactions would be ideal.

In V22 flatbuffers' JSON support takes over ptree with RPC 2.0. Migration to the new RPC version will remove this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yousifa picture yousifa  路  5Comments

androm3da picture androm3da  路  3Comments

FndNur1Labs picture FndNur1Labs  路  6Comments

BitDesert picture BitDesert  路  6Comments

bbedward picture bbedward  路  3Comments