Jump to content

JSON: Difference between revisions

1,052 bytes added ,  1 year ago
no edit summary
No edit summary
No edit summary
Line 1,702:
}
</pre>
 
 
 
 
=={{header|FutureBasic}}==
FB has dedicated JSON functions making easy to serialize objects as JSON and to convert JSON to objects.
<lang futurebasic>
include "NSLog.incl"
 
local fn DoIt
ErrorRef err = NULL
CFStringRef jsonString = @"{ \"foo\": 1, \"bar\": [10, \"apples\"] }"
CFDataRef strData = fn StringData( jsonString, NSUTF8StringEncoding )
CFTypeRef jsonObj = fn JSONSerializationJSONObjectWithData( strData, NULL, @err )
if err then NSLog( @"%@", fn ErrorLocalizedDescription( err ) )
NSLog( @"%@\n", jsonObj )
CfDictionaryRef dict = @{ @"blue": @[@1, @2], @"ocean": @"water"}
CFDataRef jsonData = fn JSONSerializationDataWithJSONObject( dict, 0, @err )
if err then NSLog( @"%@", fn ErrorLocalizedDescription( err ) )
CFStringRef jsonString2 = fn StringWithData( jsonData, NSUTF8StringEncoding )
NSLog( @"%@\n", jsonString2 )
end fn
 
fn DoIt
 
HandleEvents
</lang>
{{output}}
<pre>
{
bar = (
10,
apples
);
foo = 1;
}
 
{"blue":[1,2],"ocean":"water"}
</pre>
 
 
 
 
 
=={{header|Go}}==
Line 1,820 ⟶ 1,865:
]
</pre>
 
 
 
 
=={{header|Gosu}}==
729

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.