0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 16:22:35 +01:00
construct/include/ircd/json
2019-09-23 20:11:20 -07:00
..
tuple ircd::json: Add name-based operations to tuple::keys::selection. 2019-08-17 00:39:12 -07:00
array.h ircd::json::array: Deinline various. 2019-02-21 14:00:00 -08:00
iov.h ircd::json::iov: Fix declarations. 2019-06-21 04:31:38 -07:00
json.h ircd::json: Split some print_error cases into print_panic; relax print_error; minor cleanup. 2019-09-09 19:03:23 -07:00
member.h ircd::json: Deinline member ctor. 2019-09-13 16:32:26 -07:00
object.h ircd::json: Fix out-of-line definition return type. 2019-06-21 03:41:13 -07:00
README.md ircd::json: Fix README formatting. 2018-01-22 00:54:52 -08:00
stack.h ircd::json::stack: Add class member counters; assertions; conditions. 2019-09-23 20:11:20 -07:00
string.h ircd::json: Stub an unescape(). 2019-08-02 15:04:29 -07:00
strung.h ircd::json: Add splice operations over json::strung. 2018-09-05 19:37:59 -07:00
tool.h ircd::json: Add candidate vector merge impl. 2019-02-27 15:52:39 -08:00
type.h ircd::json: Add strict check overload to type() suite. 2019-03-28 21:01:56 -07:00
util.h ircd: Apply noexcept on various constexpr callstacks. 2019-08-15 00:05:48 -07:00
value.h ircd::json: Improve and inline value comparison operators. 2019-07-15 11:06:01 -07:00
vector.h ircd::json: Add vector utility methods to interface. 2019-02-27 11:23:52 -08:00

JavaScript Object Notation

formal grammars & tools

The IRCd JSON subsystem is meant to be a fast, safe, and extremely lightweight interface. We have taken a somewhat non-traditional approach and it's important for the developer to understand a few things.

Most JSON interfaces are functions to convert some JSON input to and from text into native-machine state like JSON.parse() for JS, boost::ptree, etc. For a parsing operation, they make a pass recursing over the entire text, allocating native structures, copying data into them, indexing their keys, and perhaps performing native-type conversions and checks to present the user with a final tree of machine-state usable in their language. The original input is then discarded.

Instead, we are interested in having the ability to compute directly over JSON text itself, and perform the allocating, indexing, copying and converting entirely at the time and place of our discretion -- if ever.

The core of this system is a robust and efficient abstract formal grammar built with boost::spirit. The formal grammar provides a proof of robustness: security vulnerabilities are more easily spotted by vetting this grammar rather than laboriously tracing the program flow of an informal handwritten parser.

Next we have taught boost::spirit how to parse into std::string_view rather than std::string. Parsing is now a composition of pointers into the original string of JSON. No dynamic allocation ever takes place. No copying of data ever takes place. IRCd can service an entire request from the original network input with absolutely minimal requisite cost.

The output side is also ambitious but probably a little more friendly to the developer. We leverage boost::spirit here also providing formally proven output safety. In other words, the grammar prevents exploits like injecting and terminating JSON as it composes the output.