Skip to content

Commit

Permalink
git-svn-id: http://bmx-rjson.googlecode.com/svn/trunk@20 01b81d83-73d…
Browse files Browse the repository at this point in the history
…2-0bb8-1479-8f8db6b56872
  • Loading branch information
Tylerbot authored and Tylerbot committed Mar 22, 2012
1 parent 9fdd1d3 commit 4a77fda
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
35 changes: 35 additions & 0 deletions rjson-test.bmx
Original file line number Diff line number Diff line change
Expand Up @@ -806,4 +806,39 @@ Catch ex$
End Try


'////////////////////////////////////////
'Print( "~ntest 7.3 - implicit type conversion on array elements" )
Try
Rem
jstr = "[1,1.5,~q5~q,~q5.5~q]"
Type Imp
Field _int$
Field _float$
Field _str_int%
Field _str_float#
EndType
Local obj:Imp = Imp( JSON.Decode( jstr,, TTypeId.ForName("Imp") ))
Print JSON.Encode( obj )
EndRem
Catch ex$
Print "Test FAILED: "+ex
End Try

Rem
'////////////////////////////////////////
Print( "~ntest 7.4 - ignored decoded fields by name" )
Try
jstr = "{~qa~q:1,~qb~q:2}"
Type SimpleType1
Field a%
EndType
Local ds:TJSONDecodeSettings = New TJSONDecodeSettings
ds.IgnoreFieldName( TTypeId.ForName("SimpleType1"), "b" )
Local s:SimpleType1 = SimpleType1( JSON.Decode( jstr, ds, TTypeId.ForName("SimpleType1") ))
Print JSON.Encode( s )
Catch ex$
Print "Test FAILED: "+ex
End Try
EndRem


3 changes: 1 addition & 2 deletions rjson.bmx
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,7 @@ Type JSON
object_field.Set( decoded_object, _InitializeArray( json_child_array, settings, object_field_type_id ))
End If
Else
Throw( "Error: could not find "+type_id.Name()+"."+key )
Return Null
'Ignore this error, there was extra data
End If
Next
Return decoded_object
Expand Down

0 comments on commit 4a77fda

Please sign in to comment.