Thrift::Protocol::JsonProtocol
Inherits Thrift::Protocol::BaseProtocol < Reference < Object
JsonProtocol writes values to a transport in valid JSON Format
Constants
This table describes the handling for the first 0x30 characters 0 : escape using "\u00xx" notation 1 : just output index <other> : escape using "<other>" notation
Constructors
Class methods
Read 1 character from the trans and verify that it is the expected character ch. Throw a protocol exception if it is not.
Instance methods
Reads a Thrift Binary (Thrift String without encoding). In Crystal 1.5.2 and onward, all Strings will be returned with an Encoding of BINARY.
Returns a String.
Decodes the four hex parts of a JSON escaped string character and returns the character via out.
Note - this only supports Unicode characters in the BMP (U+0000 to U+FFFF); characters above the BMP are encoded as two escape sequences (surrogate pairs), which is not yet implemented
Reads a sequence of characters and assembles them into a number, returning them via num
Reads a sequence of characters, stopping at the first one that is not a valid JSON numeric character.
Decodes a JSON string, including unescaping, and returns the string via str
Reads a Thrift String. In Crystal 1.5.2 and onward, all Strings will be returned with an Encoding of UTF-8.
Returns a String.
Writes a Thrift Binary (Thrift String with no encoding). In Crystal 1.5.2 and onward
buf - The Bytes to write
Returns nothing.
Write out the contents of the string as JSON string, base64-encoding the string's contents, and escaping as appropriate
Convert the given double to a JSON string, which is either the number, "NaN" or "Infinity" or "-Infinity".
Convert the given integer type to a JSON number, or a string if the context requires it (eg: key in a map pair).
Write out the contents of the string str as a JSON string, escaping characters as appropriate.
Writes a Thrift String. In Crystal 1.5.2 and onward, the String passed will be transcoded to UTF-8.
str - The String to write.
Raises EncodingError if the transcoding to UTF-8 fails.
Returns nothing.