ÿØÿà JFIF ÿÛ „ ( %!1!%)+//.383,7(-.+
-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ ¥2" ÿÄ ÿÄ J ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ ÿÄ * !1AQa‘"2q3±ð#b¡ÿÚ ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁTÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßwpŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
?>
.........................................
.............................................................................
ÿØÿà JFIF ÿÛ „
(
%!1!%)+//.383,7(-.+
-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ ¥2" ÿÄ
ÿÄ J ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ
ÿÄ * !1AQa‘"2q3±ð#b¡ÿÚ
? ¼QxJQaÍuò¸Zö
Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁTÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßwpŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
?>
.........................................
.............................................................................
????????????????????????????????????
????????????????????????????????????
ÿØÿà JFIF ÿÛ „ ( %!1!%)+//.383,7(-.+
-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ ¥2" ÿÄ ÿÄ J ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ ÿÄ * !1AQa‘"2q3±ð#b¡ÿÚ ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁTÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßwpŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
?>
.........................................
.............................................................................
ÿØÿà JFIF ÿÛ „
(
%!1!%)+//.383,7(-.+
-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ ¥2" ÿÄ
ÿÄ J ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ
ÿÄ * !1AQa‘"2q3±ð#b¡ÿÚ
? ¼QxJQaÍuò¸Zö
Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁTÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßwpŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
?>
.........................................
.............................................................................
????????????????????????????????????
????????????????????????????????????
U:RDoc::NormalModule[iI" JSON:ET@0o:RDoc::Markup::Document:@parts[
o;;[ :
@fileI"#ext/json/generator/generator.c;T:0@omit_headings_from_table_of_contents_below0o;;[S:RDoc::Markup::Heading:
leveli: textI"(JavaScript \Object Notation (\JSON);To:RDoc::Markup::BlankLine o:RDoc::Markup::Paragraph;[I"4\JSON is a lightweight data-interchange format.;T@o;;[I"+A \JSON value is one of the following:;To:RDoc::Markup::List:
@type:BULLET:@items[o:RDoc::Markup::ListItem:@label0;[o;;[I")Double-quoted text: "foo".;To;;0;[o;;[I""Number: +1+, +1.0+, +2.0e2+.;To;;0;[o;;[I"Boolean: +true+, +false+.;To;;0;[o;;[I"Null: +null+.;To;;0;[o;;[I"D\Array: an ordered list of values, enclosed by square brackets:;To:RDoc::Markup::Verbatim;[I"/["foo", 1, 1.0, 2.0e2, true, false, null]
;T:@format0o;;0;[o;;[I"J\Object: a collection of name/value pairs, enclosed by curly braces; ;TI"&each name is double-quoted text; ;TI"(the values may be any \JSON values:;To;;[I"R{"a": "foo", "b": 1, "c": 1.0, "d": 2.0e2, "e": true, "f": false, "g": null}
;T;0o;;[I"MA \JSON array or object may contain nested arrays, objects, and scalars ;TI"to any depth:;To;;[I"5{"foo": {"bar": 1, "baz": 2}, "bat": [0, 1, 2]}
;TI"([{"foo": 0, "bar": 1}, ["baz", 2]]
;T;0S;;i;
I"Using \Module \JSON;T@o;;[I"=To make module \JSON available in your code, begin with:;To;;[I"require 'json'
;T;0o;;[I"6All examples here assume that this has been done.;T@S;;i;
I"Parsing \JSON;T@o;;[I"9You can parse a \String containing \JSON data using ;TI"either of two methods:;To;;;;[o;;0;[o;;[I"&JSON.parse(source, opts);To;;0;[o;;[I"'JSON.parse!(source, opts);T@o;;[I"
where;To;;;;[o;;0;[o;;[I"+source+ is a Ruby object.;To;;0;[o;;[I"1+opts+ is a \Hash object containing options ;TI";that control both input allowed and output formatting.;T@o;;[
I",The difference between the two methods ;TI"+is that JSON.parse! omits some checks ;TI"1and may not be safe for some +source+ data; ;TI"0use it only for data from trusted sources. ;TI">Use the safer method JSON.parse for less trusted sources.;T@S;;i ;
I"Parsing \JSON Arrays;T@o;;[I"QWhen +source+ is a \JSON array, JSON.parse by default returns a Ruby \Array:;To;;[ I"8json = '["foo", 1, 1.0, 2.0e2, true, false, null]'
;TI"ruby = JSON.parse(json)
;TI"8ruby # => ["foo", 1, 1.0, 200.0, true, false, nil]
;TI"ruby.class # => Array
;T;0o;;[I"EThe \JSON array may contain nested arrays, objects, and scalars ;TI"to any depth:;To;;[I"1json = '[{"foo": 0, "bar": 1}, ["baz", 2]]'
;TI">JSON.parse(json) # => [{"foo"=>0, "bar"=>1}, ["baz", 2]]
;T;0S;;i ;
I"Parsing \JSON \Objects;T@o;;[I"SWhen the source is a \JSON object, JSON.parse by default returns a Ruby \Hash:;To;;[ I"[json = '{"a": "foo", "b": 1, "c": 1.0, "d": 2.0e2, "e": true, "f": false, "g": null}'
;TI"ruby = JSON.parse(json)
;TI"[ruby # => {"a"=>"foo", "b"=>1, "c"=>1.0, "d"=>200.0, "e"=>true, "f"=>false, "g"=>nil}
;TI"ruby.class # => Hash
;T;0o;;[I"FThe \JSON object may contain nested arrays, objects, and scalars ;TI"to any depth:;To;;[I">json = '{"foo": {"bar": 1, "baz": 2}, "bat": [0, 1, 2]}'
;TI"KJSON.parse(json) # => {"foo"=>{"bar"=>1, "baz"=>2}, "bat"=>[0, 1, 2]}
;T;0S;;i ;
I"Parsing \JSON Scalars;T@o;;[I"AWhen the source is a \JSON scalar (not an array or object), ;TI"&JSON.parse returns a Ruby scalar.;T@o;;[I"
\String:;To;;[I" ruby = JSON.parse('"foo"')
;TI"ruby # => 'foo'
;TI"ruby.class # => String
;T;0o;;[I"\Integer:;To;;[I"ruby = JSON.parse('1')
;TI"ruby # => 1
;TI"ruby.class # => Integer
;T;0o;;[I"\Float:;To;;[I"ruby = JSON.parse('1.0')
;TI"ruby # => 1.0
;TI"ruby.class # => Float
;TI" ruby = JSON.parse('2.0e2')
;TI"ruby # => 200
;TI"ruby.class # => Float
;T;0o;;[I"
Boolean:;To;;[I"ruby = JSON.parse('true')
;TI"ruby # => true
;TI"ruby.class # => TrueClass
;TI" ruby = JSON.parse('false')
;TI"ruby # => false
;TI" ruby.class # => FalseClass
;T;0o;;[I"
Null:;To;;[I"ruby = JSON.parse('null')
;TI"ruby # => nil
;TI"ruby.class # => NilClass
;T;0S;;i ;
I"Parsing Options;T@S;;i;
I"Input Options;T@o;;[I"ROption +max_nesting+ (\Integer) specifies the maximum nesting depth allowed; ;TI"Bdefaults to +100+; specify +false+ to disable depth checking.;T@o;;[I"With the default, +false+:;To;;[I"#source = '[0, [1, [2, [3]]]]'
;TI"ruby = JSON.parse(source)
;TI""ruby # => [0, [1, [2, [3]]]]
;T;0o;;[I"Too deep:;To;;[I"=# Raises JSON::NestingError (nesting of 2 is too deep):
;TI"*JSON.parse(source, {max_nesting: 1})
;T;0o;;[I"Bad value:;To;;[I"H# Raises TypeError (wrong argument type Symbol (expected Fixnum)):
;TI"-JSON.parse(source, {max_nesting: :foo})
;T;0S:RDoc::Markup::Rule:weighti@o;;[I"=Option +allow_nan+ (boolean) specifies whether to allow ;TI"3NaN, Infinity, and MinusInfinity in +source+; ;TI"defaults to +false+.;T@o;;[I"With the default, +false+:;To;;[I"D# Raises JSON::ParserError (225: unexpected token at '[NaN]'):
;TI"JSON.parse('[NaN]')
;TI"I# Raises JSON::ParserError (232: unexpected token at '[Infinity]'):
;TI"JSON.parse('[Infinity]')
;TI"J# Raises JSON::ParserError (248: unexpected token at '[-Infinity]'):
;TI"JSON.parse('[-Infinity]')
;T;0o;;[I"Allow:;To;;[I"+source = '[NaN, Infinity, -Infinity]'
;TI"2ruby = JSON.parse(source, {allow_nan: true})
;TI"*ruby # => [NaN, Infinity, -Infinity]
;T;0S;;i;
I"Output Options;T@o;;[I"NOption +symbolize_names+ (boolean) specifies whether returned \Hash keys ;TI"should be Symbols; ;TI"'defaults to +false+ (use Strings).;T@o;;[I"With the default, +false+:;To;;[I"Isource = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
;TI"ruby = JSON.parse(source)
;TI"Gruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil}
;T;0o;;[I"Use Symbols:;To;;[I"8ruby = JSON.parse(source, {symbolize_names: true})
;TI"Bruby # => {:a=>"foo", :b=>1.0, :c=>true, :d=>false, :e=>nil}
;T;0S;;i@o;;[I"HOption +object_class+ (\Class) specifies the Ruby class to be used ;TI"for each \JSON object; ;TI"defaults to \Hash.;T@o;;[I"With the default, \Hash:;To;;[I"Isource = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
;TI"ruby = JSON.parse(source)
;TI"ruby.class # => Hash
;T;0o;;[I"Use class \OpenStruct:;To;;[I";ruby = JSON.parse(source, {object_class: OpenStruct})
;TI"Druby # => #
;T;0S;;i@o;;[I"GOption +array_class+ (\Class) specifies the Ruby class to be used ;TI"for each \JSON array; ;TI"defaults to \Array.;T@o;;[I"With the default, \Array:;To;;[I"0source = '["foo", 1.0, true, false, null]'
;TI"ruby = JSON.parse(source)
;TI"ruby.class # => Array
;T;0o;;[I"Use class \Set:;To;;[I"3ruby = JSON.parse(source, {array_class: Set})
;TI"6ruby # => #
;T;0S;;i@o;;[I"^Option +create_additions+ (boolean) specifies whether to use \JSON additions in parsing. ;TI">See {\JSON Additions}[#module-JSON-label-JSON+Additions].;T@S;;i;
I"Generating \JSON;T@o;;[I"7To generate a Ruby \String containing \JSON data, ;TI";use method JSON.generate(source, opts), where;To;;;;[o;;0;[o;;[I"+source+ is a Ruby object.;To;;0;[o;;[I"1+opts+ is a \Hash object containing options ;TI";that control both input allowed and output formatting.;T@S;;i ;
I"!Generating \JSON from Arrays;T@o;;[I"=When the source is a Ruby \Array, JSON.generate returns ;TI"(a \String containing a \JSON array:;To;;[I"ruby = [0, 's', :foo]
;TI" json = JSON.generate(ruby)
;TI"json # => '[0,"s","foo"]'
;T;0o;;[I"JThe Ruby \Array array may contain nested arrays, hashes, and scalars ;TI"to any depth:;To;;[I"*ruby = [0, [1, 2], {foo: 3, bar: 4}]
;TI" json = JSON.generate(ruby)
;TI"-json # => '[0,[1,2],{"foo":3,"bar":4}]'
;T;0S;;i ;
I"!Generating \JSON from Hashes;T@o;;[I" '{"foo":0,"bar":"s","baz":"bat"}'
;T;0o;;[I"IThe Ruby \Hash array may contain nested arrays, hashes, and scalars ;TI"to any depth:;To;;[I" '{"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}'
;T;0S;;i ;
I"(Generating \JSON from Other Objects;T@o;;[I"7When the source is neither an \Array nor a \Hash, ;TI"Athe generated \JSON data depends on the class of the source.;T@o;;[I"IWhen the source is a Ruby \Integer or \Float, JSON.generate returns ;TI")a \String containing a \JSON number:;To;;[I"!JSON.generate(42) # => '42'
;TI"%JSON.generate(0.42) # => '0.42'
;T;0o;;[I">When the source is a Ruby \String, JSON.generate returns ;TI">a \String containing a \JSON string (with double-quotes):;To;;[I"1JSON.generate('A string') # => '"A string"'
;T;0o;;[I"HWhen the source is +true+, +false+ or +nil+, JSON.generate returns ;TI"8a \String containing the corresponding \JSON token:;To;;[I"%JSON.generate(true) # => 'true'
;TI"'JSON.generate(false) # => 'false'
;TI"$JSON.generate(nil) # => 'null'
;T;0o;;[I"AWhen the source is none of the above, JSON.generate returns ;TI"Fa \String containing a \JSON string representation of the source:;To;;[I"&JSON.generate(:foo) # => '"foo"'
;TI"0JSON.generate(Complex(0, 0)) # => '"0+0i"'
;TI"1JSON.generate(Dir.new('.')) # => '"#"'
;T;0S;;i ;
I"Generating Options;T@S;;i;
I"Input Options;T@o;;[I"4Option +allow_nan+ (boolean) specifies whether ;TI"A+NaN+, +Infinity+, and -Infinity may be generated; ;TI"defaults to +false+.;T@o;;[I"With the default, +false+:;To;;[I"C# Raises JSON::GeneratorError (920: NaN not allowed in JSON):
;TI"JSON.generate(JSON::NaN)
;TI"H# Raises JSON::GeneratorError (917: Infinity not allowed in JSON):
;TI"#JSON.generate(JSON::Infinity)
;TI"I# Raises JSON::GeneratorError (917: -Infinity not allowed in JSON):
;TI"(JSON.generate(JSON::MinusInfinity)
;T;0o;;[I"Allow:;To;;[I"@ruby = [Float::NaN, Float::Infinity, Float::MinusInfinity]
;TI"JJSON.generate(ruby, allow_nan: true) # => '[NaN,Infinity,-Infinity]'
;T;0S;;i@o;;[I"IOption +max_nesting+ (\Integer) specifies the maximum nesting depth ;TI"!in +obj+; defaults to +100+.;T@o;;[I"With the default, +100+:;To;;[I"obj = [[[[[[0]]]]]]
;TI"-JSON.generate(obj) # => '[[[[[[0]]]]]]'
;T;0o;;[I"Too deep:;To;;[I"=# Raises JSON::NestingError (nesting of 2 is too deep):
;TI"(JSON.generate(obj, max_nesting: 2)
;T;0S;;i;
I"Escaping Options;T@o;;[I"[Options +script_safe+ (boolean) specifies wether '\u2028', '\u2029' ;TI"aand '/' should be escaped as to make the JSON object safe to interpolate in script ;TI"
tags.;T@o;;[I"\Options +ascii_only+ (boolean) specifies wether all characters outside the ASCII range ;TI"should be escaped.;T@S;;i;
I"Output Options;T@o;;[I">The default formatting options generate the most compact ;TI"8\JSON data, all on one line and with no whitespace.;T@o;;[I"6You can use these formatting options to generate ;TI"9\JSON data in a more open format, using whitespace. ;TI"#See also JSON.pretty_generate.;T@o;;;;[
o;;0;[o;;[I"HOption +array_nl+ (\String) specifies a string (usually a newline) ;TI"Wto be inserted after each \JSON array; defaults to the empty \String, ''.;To;;0;[o;;[I"IOption +object_nl+ (\String) specifies a string (usually a newline) ;TI"Xto be inserted after each \JSON object; defaults to the empty \String, ''.;To;;0;[o;;[ I"KOption +indent+ (\String) specifies the string (usually spaces) to be ;TI"Gused for indentation; defaults to the empty \String, ''; ;TI"1defaults to the empty \String, ''; ;TI"Mhas no effect unless options +array_nl+ or +object_nl+ specify newlines.;To;;0;[o;;[I"IOption +space+ (\String) specifies a string (usually a space) to be ;TI";inserted after the colon in each \JSON object's pair; ;TI"0defaults to the empty \String, ''.;To;;0;[o;;[I"POption +space_before+ (\String) specifies a string (usually a space) to be ;TI"''.;T@o;;[I"CIn this example, +obj+ is used first to generate the shortest ;TI"H\JSON data (no whitespace), then again with all formatting options ;TI"specified:;T@o;;[I"6obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}}
;TI"json = JSON.generate(obj)
;TI"puts 'Compact:', json
;TI"opts = {
;TI" array_nl: "\n",
;TI" object_nl: "\n",
;TI" indent: ' ',
;TI" space_before: ' ',
;TI" space: ' '
;TI"}
;TI",puts 'Open:', JSON.generate(obj, opts)
;T;0o;;[I"Output:;To;;[I"Compact:
;TI"3{"foo":["bar","baz"],"bat":{"bam":0,"bad":1}}
;TI"Open:
;TI"{
;TI" "foo" : [
;TI" "bar",
;TI" "baz"
;TI"],
;TI" "bat" : {
;TI" "bam" : 0,
;TI" "bad" : 1
;TI" }
;TI"}
;T;0S;;i;
I"\JSON Additions;T@o;;[I"MWhen you "round trip" a non-\String object from Ruby to \JSON and back, ;TI"Byou have a new \String, instead of the object you began with:;To;;[I"ruby0 = Range.new(0, 2)
;TI"!json = JSON.generate(ruby0)
;TI"json # => '0..2"'
;TI"ruby1 = JSON.parse(json)
;TI"ruby1 # => '0..2'
;TI"ruby1.class # => String
;T;0o;;[I"DYou can use \JSON _additions_ to preserve the original object. ;TI";The addition is an extension of a ruby class, so that:;To;;;;[o;;0;[o;;[I"@\JSON.generate stores more information in the \JSON string.;To;;0;[o;;[I"9\JSON.parse, called with option +create_additions+, ;TI":uses that information to create a proper Ruby object.;T@o;;[I" Without addition: #{ruby0.inspect} (#{ruby0.class})
;TI"> With addition: #{ruby1.inspect} (#{ruby1.class})
;TI" EOT
;TI"puts display
;T;0o;;[I"-This output shows the different results:;To;;[I"Generated JSON:
;TI"* Without addition: "0..2" (String)
;TI"J With addition: {"json_class":"Range","a":[0,2,false]} (String)
;TI"Parsed JSON:
;TI"* Without addition: "0..2" (String)
;TI"' With addition: 0..2 (Range)
;T;0o;;[I">The \JSON module includes additions for certain classes. ;TI"*You can also craft custom additions. ;TI"LSee {Custom \JSON Additions}[#module-JSON-label-Custom+JSON+Additions].;T@S;;i;
I"Built-in Additions;T@o;;[I">The \JSON module includes additions for certain classes. ;TI".To use an addition, +require+ its source:;To;;;;[o;;0;[o;;[I"7BigDecimal: require 'json/add/bigdecimal';To;;0;[o;;[I"1Complex: require 'json/add/complex';To;;0;[o;;[I"+Date: require 'json/add/date';To;;0;[o;;[I"4DateTime: require 'json/add/date_time';To;;0;[o;;[I"5Exception: require 'json/add/exception';To;;0;[o;;[I"4OpenStruct: require 'json/add/ostruct';To;;0;[o;;[I"-Range: require 'json/add/range';To;;0;[o;;[I"3Rational: require 'json/add/rational';To;;0;[o;;[I"/Regexp: require 'json/add/regexp';To;;0;[o;;[I")Set: require 'json/add/set';To;;0;[o;;[I"/Struct: require 'json/add/struct';To;;0;[o;;[I"/Symbol: require 'json/add/symbol';To;;0;[o;;[I"+Time: require 'json/add/time';T@o;;[I"7To reduce punctuation clutter, the examples below ;TI"Jshow the generated \JSON via +puts+, rather than the usual +inspect+,;T@o;;[I"\BigDecimal:;To;;[
I"#require 'json/add/bigdecimal'
;TI"!ruby0 = BigDecimal(0) # 0.0
;TI"Ljson = JSON.generate(ruby0) # {"json_class":"BigDecimal","b":"27:0.0"}
;TI" BigDecimal
;T;0o;;[I"\Complex:;To;;[
I" require 'json/add/complex'
;TI""ruby0 = Complex(1+0i) # 1+0i
;TI"Hjson = JSON.generate(ruby0) # {"json_class":"Complex","r":1,"i":0}
;TI"=ruby1 = JSON.parse(json, create_additions: true) # 1+0i
;TI"ruby1.class # Complex
;T;0o;;[I"\Date:;To;;[
I"require 'json/add/date'
;TI"%ruby0 = Date.today # 2020-05-02
;TI"]json = JSON.generate(ruby0) # {"json_class":"Date","y":2020,"m":5,"d":2,"sg":2299161.0}
;TI"Cruby1 = JSON.parse(json, create_additions: true) # 2020-05-02
;TI"ruby1.class # Date
;T;0o;;[I"\DateTime:;To;;[
I""require 'json/add/date_time'
;TI"6ruby0 = DateTime.now # 2020-05-02T10:38:13-05:00
;TI"~json = JSON.generate(ruby0) # {"json_class":"DateTime","y":2020,"m":5,"d":2,"H":10,"M":38,"S":13,"of":"-5/24","sg":2299161.0}
;TI"Rruby1 = JSON.parse(json, create_additions: true) # 2020-05-02T10:38:13-05:00
;TI"ruby1.class # DateTime
;T;0o;;[I"=\Exception (and its subclasses including \RuntimeError):;To;;[I""require 'json/add/exception'
;TI"4ruby0 = Exception.new('A message') # A message
;TI"Wjson = JSON.generate(ruby0) # {"json_class":"Exception","m":"A message","b":null}
;TI"Bruby1 = JSON.parse(json, create_additions: true) # A message
;TI"ruby1.class # Exception
;TI"Cruby0 = RuntimeError.new('Another message') # Another message
;TI"`json = JSON.generate(ruby0) # {"json_class":"RuntimeError","m":"Another message","b":null}
;TI"Hruby1 = JSON.parse(json, create_additions: true) # Another message
;TI" ruby1.class # RuntimeError
;T;0o;;[I"\OpenStruct:;To;;[
I" require 'json/add/ostruct'
;TI"iruby0 = OpenStruct.new(name: 'Matz', language: 'Ruby') # #
;TI"ejson = JSON.generate(ruby0) # {"json_class":"OpenStruct","t":{"name":"Matz","language":"Ruby"}}
;TI"cruby1 = JSON.parse(json, create_additions: true) # #
;TI"ruby1.class # OpenStruct
;T;0o;;[I"\Range:;To;;[
I"require 'json/add/range'
;TI"$ruby0 = Range.new(0, 2) # 0..2
;TI"Jjson = JSON.generate(ruby0) # {"json_class":"Range","a":[0,2,false]}
;TI"=ruby1 = JSON.parse(json, create_additions: true) # 0..2
;TI"ruby1.class # Range
;T;0o;;[I"\Rational:;To;;[
I"!require 'json/add/rational'
;TI""ruby0 = Rational(1, 3) # 1/3
;TI"Ijson = JSON.generate(ruby0) # {"json_class":"Rational","n":1,"d":3}
;TI"
;TI"Djson = JSON.generate(ruby0) # {"json_class":"Set","a":[0,1,2]}
;TI"Jruby1 = JSON.parse(json, create_additions: true) # #
;TI"ruby1.class # Set
;T;0o;;[I"
\Struct:;To;;[I"require 'json/add/struct'
;TI"7Customer = Struct.new(:name, :address) # Customer
;TI"cruby0 = Customer.new("Dave", "123 Main") # #
;TI"Ujson = JSON.generate(ruby0) # {"json_class":"Customer","v":["Dave","123 Main"]}
;TI"kruby1 = JSON.parse(json, create_additions: true) # #
;TI"ruby1.class # Customer
;T;0o;;[I"
\Symbol:;To;;[
I"require 'json/add/symbol'
;TI"ruby0 = :foo # foo
;TI"Ejson = JSON.generate(ruby0) # {"json_class":"Symbol","s":"foo"}
;TI" self.class.name,
;TI"+ 'a' => [ bar, baz ]
;TI" }.to_json(*args)
;TI" end
;TI"P # Deserialize JSON string by constructing new Foo object with arguments.
;TI"$ def self.json_create(object)
;TI" new(*object['a'])
;TI" end
;TI" end
;T;0o;;[I"Demonstration:;To;;[I"require 'json'
;TI"/# This Foo object has no custom addition.
;TI"foo0 = Foo.new(0, 1)
;TI"!json0 = JSON.generate(foo0)
;TI"obj0 = JSON.parse(json0)
;TI"!# Lood the custom addition.
;TI"%require_relative 'foo_addition'
;TI")# This foo has the custom addition.
;TI"foo1 = Foo.new(0, 1)
;TI"!json1 = JSON.generate(foo1)
;TI"6obj1 = JSON.parse(json1, create_additions: true)
;TI"# Make a nice display.
;TI"display = <<~EOT
;TI" Generated JSON:
;TI"= Without custom addition: #{json0} (#{json0.class})
;TI"= With custom addition: #{json1} (#{json1.class})
;TI" Parsed JSON:
;TI"C Without custom addition: #{obj0.inspect} (#{obj0.class})
;TI"C With custom addition: #{obj1.inspect} (#{obj1.class})
;TI" EOT
;TI"puts display
;T;0o;;[I"Output:;T@o;;[I"Generated JSON:
;TI"F Without custom addition: "#" (String)
;TI"I With custom addition: {"json_class":"Foo","a":[0,1]} (String)
;TI"Parsed JSON:
;TI"F Without custom addition: "#" (String)
;TI"O With custom addition: # (Foo);T;0; I"ext/json/lib/json.rb;T;
0o;;[ ; I" ext/json/lib/json/common.rb;T;
0o;;[ ; I"ext/json/lib/json/ext.rb;T;
0o;;[ ; I"-ext/json/lib/json/ext/generator/state.rb;T;
0o;;[ ; I"(ext/json/lib/json/generic_object.rb;T;
0o;;[ ; I"!ext/json/lib/json/version.rb;T;
0o;;[ ; I"ext/json/parser/parser.c;T;
0; 0;
0[[
I"dump_default_options;TI"RW;T:publicTI" ext/json/lib/json/common.rb;T[
I"generator;TI"R;T;T@[
I"load_default_options;T@;T@[
I"parser;T@;T@[
I"
state;T@;T@[
I" unsafe_load_default_options;T@;T@[U:RDoc::Constant[i I"NOT_SET;TI"JSON::NOT_SET;T:private0o;;[ ; @;
0@@cRDoc::NormalModule0U;[i I"NaN;TI"JSON::NaN;T;0o;;[ ; @;
0@@@0U;[i I"
Infinity;TI"JSON::Infinity;T;0o;;[ ; @;
0@@@0U;[i I"MinusInfinity;TI"JSON::MinusInfinity;T;0o;;[ ; @;
0@@@0U;[i I"JSON_LOADED;TI"JSON::JSON_LOADED;T;0o;;[ ; @;
0@@@0U;[i I"VERSION;TI"JSON::VERSION;T;0o;;[ ; @;
0@@@0[ [[I"
class;T[[;[[I"[];T@[I"create_fast_state;T@[I"create_id;T@[I"create_id=;T@[I"create_pretty_state;T@[I"
iconv;T@[I"restore;T@[:protected[ [;[ [I"
instance;T[[;[[I" dump;T@[I"fast_generate;T@[I"
generate;T@[I" load;T@[I"load_file;T@[I"load_file!;T@[I"merge_dump_options;T@[I"
parse;T@[I"parse!;T@[I"pretty_generate;T@[I"unsafe_load;T@[;[ [;[[@@[ [U:RDoc::Context::Section[i 0o;;[ ; 0;
0[@@I"(ext/json/lib/json/add/bigdecimal.rb;TI"%ext/json/lib/json/add/complex.rb;TI""ext/json/lib/json/add/date.rb;TI"'ext/json/lib/json/add/date_time.rb;TI"'ext/json/lib/json/add/exception.rb;TI"%ext/json/lib/json/add/ostruct.rb;TI"#ext/json/lib/json/add/range.rb;TI"&ext/json/lib/json/add/rational.rb;TI"$ext/json/lib/json/add/regexp.rb;TI"!ext/json/lib/json/add/set.rb;TI"$ext/json/lib/json/add/struct.rb;TI"$ext/json/lib/json/add/symbol.rb;TI""ext/json/lib/json/add/time.rb;T@@@@@@@cRDoc::TopLevel