Module | JSON
In: | lib/facets/more/json.rb

This module is the namespace for all the JSON related classes. It also defines some module functions to expose a nicer API to users, instead of using the parser and other classes directly.

### Methods

parse pretty_unparse support_unicode= support_unicode? unparse utf16_to_utf8 utf8_to_json utf8_to_utf16

### Classes and Modules

Class JSON::Parser
Class JSON::State

### Constants

JSONError | = | Class.new StandardError |  | The base exception for JSON errors.
ParserError | = | Class.new JSONError |  | This exception is raise, if a parser error occurs.
UnparserError | = | Class.new JSONError |  | This exception is raise, if a unparser error occurs.
CircularDatastructure | = | Class.new UnparserError |  | If a circular data structure is encountered while unparsing this exception is raised.
UTF16toUTF8 | = | Iconv.new('utf-8', 'utf-16be') |  | An iconv instance to convert from UTF8 to UTF16 Big Endian.
UTF8toUTF16 | = | Iconv.new('utf-16be', 'utf-8'); |  | An iconv instance to convert from UTF16 Big Endian to UTF8.

### Public Class methods

support_unicode=(enable)

Switches on Unicode support, if enable is true. Otherwise switches Unicode support off.

support_unicode?()

Returns true if JSON supports unicode, otherwise false is returned.

### Public Instance methods

parse(source)

Parse the JSON string source into a Ruby data structure and return it.

pretty_unparse(obj)

Unparse the Ruby data structure obj into a JSON string and return it. The returned string is a prettier form of the string returned by unparse.

unparse(obj, state = nil)

Unparse the Ruby data structure obj into a single line JSON string and return it. state is a JSON::State object, that can be used to configure the output further.

utf16_to_utf8(string)

Convert string from UTF16 (big endian) encoding to UTF8 encoding and return it.

utf8_to_json(string)

Convert a UTF8 encoded Ruby string string to a JSON string, encoded with UTF16 big endian characters as \u????, and return it.

utf8_to_utf16(string)

Convert string from UTF8 encoding to UTF16 (big endian) encoding and return it.

[Validate]