JSON: Difference between revisions

Content added Content deleted
(→‎{{header|Raku}}: simplification)
(JSON in FreeBASIC)
Line 1,678: Line 1,678:
end program json_fortran
end program json_fortran
</syntaxhighlight>
</syntaxhighlight>

=={{header|FreeBASIC}}==
{{libheader|YAJL}}
[https://github.com/mrozbarry/fbjson FreeBASIC JSON Parser] "JSON is simple, so the interface should also be simple" Written by Oz (alex DOT barry AT gmail DOT com) - April 22, 2010, Updated May 21, 2013

Sample JSON file:
<syntaxhighlight>{
"menu": { "id": "file",
"string": "File:",
"number": -3,
"boolean1":true , "boolean2" :false,"boolean3":true,
"sentence" : "the rain in spain falls mainly on the plain. This here \" is an escaped quote!",
"null": null,
"array" : [0,1,2,3]
"Thumbnail": {
"Url": "http://www.example.com/image/481989943",
"Height": 125,
"Width": "100"
},
}
}</syntaxhighlight>


<syntaxhighlight lang="vb">#include "inc/fbJSON.bas"

Sub printNodeChildren(Byval n As fbJSON Ptr, Byval level As Integer)
End Sub

Dim test As fbJSON Ptr = fbJSON_ImportFile("test1.json")

If test = NULL Then
Print "Unable to load json file/string!"
End 1
End If

Print fbJSON_ExportString(test, 1)

fbJSON_Delete(test)

Sleep</syntaxhighlight>
{{out}}
<pre>{
"menu": {
"id" : "file",
"string" : "File:",
"number" : -3,
"boolean1" : true,
"boolean2" : false,
"boolean3" : true,
"sentence" : "the rain in spain falls mainly on the plain. This here " is an escaped quote!",
"null" : null,
"array": [ 0, 1, 2, 3 ]
,
"Thumbnail": {
"Url" : "http://www.example.com/image/481989943",
"Height" : 125,
"Width" : "100"
}

}

}</pre>


=={{header|FunL}}==
=={{header|FunL}}==