Module | ActiveSupport::OkJson |
In: |
lib/active_support/json/backends/okjson.rb
|
Some parts adapted from golang.org/src/pkg/json/decode.go and golang.org/src/pkg/utf8/utf8.go
Upstream | = | 'LTD7LBKLZWFF7OZK' |
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 |
Ustrerr | = | "\xef\xbf\xbd" |
Usurrself | = | 0x10000 |
Usurr1 | = | 0xd800 |
Usurr2 | = | 0xdc00 |
Usurr3 | = | 0xe000 |
Spc | = | ' '[0] |
Unesc | = | {?b=>?\b, ?f=>?\f, ?n=>?\n, ?r=>?\r, ?t=>?\t} |
Decodes a json document in string s and returns the corresponding ruby value. String s must be valid UTF-8. If you have a string in some other encoding, convert it first.
String values in the resulting structure will be UTF-8.
Encodes x into a json text. It may contain only Array, Hash, String, Numeric, true, false, nil. (Note, this list excludes Symbol.) X itself must be an Array or a Hash. No other value can be encoded, and an error will be raised if x contains any other value, such as Nan, Infinity, Symbol, and Proc, or if a Hash key is not a String. Strings contained in x must be valid UTF-8.
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 s does not begin with a valid token.
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.
Copies the valid UTF-8 bytes of a single character from string s at position i to I/O object t, and returns the number of bytes copied. If no valid UTF-8 char exists at position i, ucharcopy writes Ustrerr and returns 1.
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 an error if q contains control characters.