Module | OkJson |
In: |
lib/vendor/okjson.rb
|
Some parts adapted from golang.org/src/pkg/json/decode.go and golang.org/src/pkg/utf8/utf8.go
Utagx | = | 0x80 |
Utag2 | = | 0xc0 |
Utag3 | = | 0xe0 |
Utag4 | = | 0xf0 |
Utag5 | = | 0xF8 |
Umaskx | = | 0x3f |
Umask2 | = | 0x1f |
Umask3 | = | 0x0f |
Umask4 | = | 0x07 |
Uchar1max | = | (1<<7) - 1 |
Uchar2max | = | (1<<11) - 1 |
Uchar3max | = | (1<<16) - 1 |
Ucharerr | = | 0xFFFD |
Usurrself | = | 0x10000 |
Usurr1 | = | 0xd800 |
Usurr2 | = | 0xdc00 |
Usurr3 | = | 0xe000 |
Umax | = | 0x10ffff |
Spc | = | ' '[0] |
Unesc | = | {?b=>?\b, ?f=>?\f, ?n=>?\n, ?r=>?\r, ?t=>?\t} |
Hex | = | '0123456789abcdef' |
Encodes x into a json text. It may contain only Array, Hash, String, Numeric, true, false, nil. (Note, this list excludes Symbol.) Strings contained in x must be valid UTF-8. Values that cannot be represented, such as Nan, Infinity, Symbol, and Proc, are encoded as null, in accordance with ECMA-262, 5th ed.
Parses a "json text" in the sense of RFC 4627. Returns the parsed value and any trailing tokens. Note: this is almost the same as valparse, except that it does not accept atomic values.
Scans the first token in s and returns a 3-element list, or nil if no such token exists.
The first list element is one of ’{’, ’}’, ’:’, ’,’, ’[’, ’]’, :val, :str, and :space.
The second element is the lexeme.
The third element is the value of the token for :val and :str, otherwise it is the lexeme.
Decodes unicode character u from UTF-8 bytes in string s at position i. Returns u and the number of bytes read.
Encodes unicode character u as UTF-8 bytes in string a at position i. Returns the number of bytes written.
Converts a quoted json string literal q into a UTF-8-encoded string. The rules are different than for Ruby, so we cannot use eval. Unquote will raise OkJson::ParserError, an error if q contains control characters.