Unverified Commit badade33 authored by Kenton Varda's avatar Kenton Varda Committed by GitHub

Merge pull request #677 from RReverser/json-decode

Rewrite JSON decoding
parents 3d97775b 2d14ff20
...@@ -17,6 +17,7 @@ Harris Hancock <vortrab@gmail.com>: MSVC support ...@@ -17,6 +17,7 @@ Harris Hancock <vortrab@gmail.com>: MSVC support
Branislav Katreniak <branislav.katreniak@digitalstrom.com>: JSON decode Branislav Katreniak <branislav.katreniak@digitalstrom.com>: JSON decode
Matthew Maurer <matthew.r.maurer@gmail.com>: Canonicalization Support Matthew Maurer <matthew.r.maurer@gmail.com>: Canonicalization Support
David Renshaw <david@sandstorm.io>: bugfixes and miscellaneous maintenance David Renshaw <david@sandstorm.io>: bugfixes and miscellaneous maintenance
Ingvar Stepanyan <me@rreverser.com> <ingvar@cloudflare.com>: Custom handlers for JSON decode
This file does not list people who maintain their own Cap'n Proto This file does not list people who maintain their own Cap'n Proto
implementations as separate projects. Those people are awesome too! :) implementations as separate projects. Those people are awesome too! :)
This diff is collapsed.
This diff is collapsed.
...@@ -49,7 +49,7 @@ class JsonCodec { ...@@ -49,7 +49,7 @@ class JsonCodec {
// - 64-bit integers are encoded as strings, since JSON "numbers" are double-precision floating // - 64-bit integers are encoded as strings, since JSON "numbers" are double-precision floating
// points which cannot store a 64-bit integer without losing data. // points which cannot store a 64-bit integer without losing data.
// - NaNs and infinite floating point numbers are not allowed by the JSON spec, and so are encoded // - NaNs and infinite floating point numbers are not allowed by the JSON spec, and so are encoded
// as null. This matches the behavior of `JSON.stringify` in at least Firefox and Chrome. // as strings.
// - Data is encoded as an array of numbers in the range [0,255]. You probably want to register // - Data is encoded as an array of numbers in the range [0,255]. You probably want to register
// a handler that does something better, like maybe base64 encoding, but there are a zillion // a handler that does something better, like maybe base64 encoding, but there are a zillion
// different ways people do this. // different ways people do this.
...@@ -220,8 +220,8 @@ private: ...@@ -220,8 +220,8 @@ private:
void encodeField(StructSchema::Field field, DynamicValue::Reader input, void encodeField(StructSchema::Field field, DynamicValue::Reader input,
JsonValue::Builder output) const; JsonValue::Builder output) const;
void decodeArray(List<JsonValue>::Reader input, DynamicList::Builder output) const; Orphan<DynamicList> decodeArray(List<JsonValue>::Reader input, ListSchema type, Orphanage orphanage) const;
void decodeObject(List<JsonValue::Field>::Reader input, DynamicStruct::Builder output) const; void decodeObject(JsonValue::Reader input, StructSchema type, Orphanage orphanage, DynamicStruct::Builder output) const;
void addTypeHandlerImpl(Type type, HandlerBase& handler); void addTypeHandlerImpl(Type type, HandlerBase& handler);
void addFieldHandlerImpl(StructSchema::Field field, Type type, HandlerBase& handler); void addFieldHandlerImpl(StructSchema::Field field, Type type, HandlerBase& handler);
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment