Sha256: 3875a261d0f0f3219ef0d6a8b9d78bd367eca164317d5b8337126e4d6f578f30

Contents?: true

Size: 902 Bytes

Versions: 27

Compression:

Stored size: 902 Bytes

Contents

describe "JSON.parse" do
  it "parses null into nil" do
    JSON.parse("null").should be_nil
  end

  it "parses true into true" do
    JSON.parse("true").should be_true
  end

  it "parses false into false" do
    JSON.parse("false").should be_false
  end

  it "parses numbers into numbers" do
    JSON.parse("42").should == 42
    JSON.parse("3.142").should == 3.142
  end

  it "parses arrays into ruby arrays" do
    JSON.parse("[]").should == []
    JSON.parse("[1, 2, 3]").should == [1, 2, 3]
    JSON.parse("[[1, 2, 3], [4, 5]]").should == [[1, 2, 3], [4, 5]]
    JSON.parse("[null, true, false]").should == [nil, true, false]
  end

  it "parses object literals into ruby hashes" do
    JSON.parse("{}").should == {}
    JSON.parse('{"a": "b"}').should == {"a" => "b"}
    JSON.parse('{"a": null, "b": 10, "c": [true, false]}').should == {"a" => nil, "b" => 10, "c" => [true, false]}
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
opal-0.4.2 spec/opal/json/parse_spec.rb
opal-0.4.1 spec/opal/json/parse_spec.rb
opal-0.4.0 spec/opal/json/parse_spec.rb
opal-0.3.44 spec/rubyspec/core/json/parse_spec.rb
opal-0.3.43 spec/rubyspec/core/json/parse_spec.rb
opal-0.3.42 spec/core/json/parse_spec.rb
opal-0.3.41 spec/core/json/parse_spec.rb
opal-0.3.40 spec/core/json/parse_spec.rb
opal-0.3.39 spec/core/json/parse_spec.rb
opal-0.3.38 spec/core/json/parse_spec.rb
opal-0.3.37 spec/core/json/parse_spec.rb
opal-0.3.36 spec/core/json/parse_spec.rb
opal-0.3.35 spec/core/json/parse_spec.rb
opal-0.3.34 spec/core/json/parse_spec.rb
opal-0.3.33 spec/core/json/parse_spec.rb
opal-0.3.32 spec/core/json/parse_spec.rb
opal-0.3.31 spec/core/json/parse_spec.rb
opal-0.3.30 spec/core/json/parse_spec.rb
opal-0.3.29 spec/core/json/parse_spec.rb
opal-0.3.28 spec/core/json/parse_spec.rb