From 003b046116f5747f2cdbfe2799e4edfcadc465cf Mon Sep 17 00:00:00 2001 From: "mattpok@google.com" Date: Tue, 24 Aug 2010 19:22:53 +0000 Subject: [PATCH] added more json parser tests git-svn-id: https://google-api-ruby-client.googlecode.com/svn/trunk@24 c1d61fac-ed7f-fcc1-18f7-ff78120a04ef --- spec/google/api_client/parser/parser_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/google/api_client/parser/parser_spec.rb b/spec/google/api_client/parser/parser_spec.rb index c8a299353..8b4b17031 100644 --- a/spec/google/api_client/parser/parser_spec.rb +++ b/spec/google/api_client/parser/parser_spec.rb @@ -25,6 +25,10 @@ describe Google::APIClient::JSONParser, 'generates json from hash' do it 'should translate simple hash to JSON string' do @parser.generate('test' => 23).should == "{\"test\":23}" end + it 'should translate simple nested into to nested JSON string' do + @parser.generate({'test' => 23, 'test2' => {'foo' => 'baz', 12 => 3.14 }}).should == + "{\"test2\":{\"12\":3.14,\"foo\":\"baz\"},\"test\":23}" + end end describe Google::APIClient::JSONParser, 'parses json string into hash' do @@ -35,5 +39,10 @@ describe Google::APIClient::JSONParser, 'parses json string into hash' do it 'should parse simple json string into hash' do @parser.parse('{"test":23}').should == {'test' => 23} end + + it 'should parse nested json object into hash' do + @parser.parse('{"test":23, "test2":{"bar":"baz", "foo":3.14}}').should == + {'test' => 23, 'test2' => {'bar' => 'baz', 'foo' => 3.14}} + end end