equal
deleted
inserted
replaced
48 ## tnetobj = parse_tnetstring( tnetstr ) |
48 ## tnetobj = parse_tnetstring( tnetstr ) |
49 ## |
49 ## |
50 ## # tnetobj is now equivalent to the structure: |
50 ## # tnetobj is now equivalent to the structure: |
51 ## # @[(key: test, val: 1.3), (key: key2, val: true), (key: things, val: @[1, 2, 3])] |
51 ## # @[(key: test, val: 1.3), (key: key2, val: true), (key: things, val: @[1, 2, 3])] |
52 ## |
52 ## |
53 ## assert ( tnetobj.kind == TNetstringObject ) |
53 ## assert( tnetobj.kind == TNetstringObject ) |
54 ## echo tnetobj[ "test" ] |
54 ## echo tnetobj[ "test" ] |
55 ## echo tnetobj[ "key2" ] |
55 ## echo tnetobj[ "key2" ] |
56 ## for item in tnetobj[ "things" ]: |
56 ## for item in tnetobj[ "things" ]: |
57 ## echo item |
57 ## echo item |
58 ## |
58 ## |
246 |
246 |
247 if ( key.extra == "" ): raiseParseErr( result, "Invalid data: Unbalanced tuple." ) |
247 if ( key.extra == "" ): raiseParseErr( result, "Invalid data: Unbalanced tuple." ) |
248 if ( key.kind != TNetstringString ): raiseParseErr( result, "Invalid data: Object keys must be strings." ) |
248 if ( key.kind != TNetstringString ): raiseParseErr( result, "Invalid data: Object keys must be strings." ) |
249 |
249 |
250 var value = parse_tnetstring( key.extra ) |
250 var value = parse_tnetstring( key.extra ) |
251 result.fields = @[] |
|
252 result.fields.add( (key: key.str, val: value) ) |
251 result.fields.add( (key: key.str, val: value) ) |
253 |
252 |
254 while value.extra != "": |
253 while value.extra != "": |
255 var subkey = parse_tnetstring( value.extra ) |
254 var subkey = parse_tnetstring( value.extra ) |
256 if ( subkey.extra == "" ): raiseParseErr( result, "Invalid data: Unbalanced tuple." ) |
255 if ( subkey.extra == "" ): raiseParseErr( result, "Invalid data: Unbalanced tuple." ) |