Documentation / @blazetrails/activesupport / JSON / parse
Function: parse()
parse(
source,opts?):unknown
Defined in: packages/ruby-compat/dist/json.d.ts:41
JSON.parse (vendor/ruby/v3.3.11/ext/json/lib/json/common.rb:219). The parser takes the source through StringValue and convert_encoding (vendor/ruby/v3.3.11/ext/json/parser/parser.rl:673-687,805), which reads an ASCII-8BIT source as UTF-8, so a source held as its bytes is decoded here. A malformed source raises SyntaxError, JS's JSON::ParserError. With an options hash an object is parsed into a Hash, its names Symbols under symbolizeNames and every value frozen under freeze (parser.rl:742-752), or into a new objectClass instance filled through its []= (parser.rl:139-143,179). Between tokens the source is read through the grammar's ignore = ws | comment (parser.rl:100-108): a block comment, and a // comment running to and including its newline, each read as whitespace; a comment left open raises SyntaxError.
Parameters
| Parameter | Type |
|---|---|
source | string | Uint8Array<ArrayBufferLike> |
opts? | { freeze?: boolean; objectClass?: () => Hash<string, unknown>; quirksMode?: boolean; symbolizeNames?: boolean; } |
opts.freeze? | boolean |
opts.objectClass? | () => Hash<string, unknown> |
opts.quirksMode? | boolean |
opts.symbolizeNames? | boolean |
Returns
unknown
No Rails Equivalent
PERMANENT — Ruby stdlib JSON.parse (vendor/ruby/v3.3.11/ext/json/lib/json/common.rb:219).