(This is a first cut, and pretty rough)
Goals:
- improve protocol compliance (don't accept YAML, escape more consistently)
- make marshalling code easier to read and write
- make contracts clearer: type system knows when we're passing JSON blobs
I've raised the general issue of adding a library on llvm-dev:
https://groups.google.com/d/topic/llvm-dev/5rryBKDY8eY/discussion
and will wait for a conclusion there too before proceeding.
Some callsites have been updated to pass JSON objects instead of
strings. The rest will be too, incrementally rather than in this patch.
This necessarily modifies the format of the output (e.g. reordering fields).
This breaks the tests, to make them more robust to this in the future
and easier to read I've canonicalized and prettyprinted the output.
We may want to put the prettyprinting behind a flag to save some spaces later.
Only a couple of tests have been updated so far, the others fail - I'll
fix them if the approach seems OK.
Things to do in future:
- have JSONRPCDispatcher/'parse' methods in Protocol use the JSON lib
- replace the 'unparse' methods in Protocol with to_json hooks
- see if we can make JSON use llvm types for strings etc
- clean up callsites that are using replyRaw