I wrote a JSON parser for FreeBASIC. It's a little different, in style and features, than Kristopher Windsor's parser, and mine is a little bulkier.news wrote:I have moved this repo to github, since I rarely use svn these days. Any further updates are going to be tossed in here. I will leave the old google code project up for historical reasons.
-Oz
11-06-2013
You can find all the information in the github project page.
To grab a fresh zip of the master branch, you can visit this link.
To see the latest updates, visit the commits section.
Update: To grab a copy from the git
In the current download, you get:git clone git://github.com/mrozbarry/fbjson.git
- fbJSON.bi and fbJSON.bas - The header/source file
- (new) UTF8String and UTF8Char UDT/Classes for handling non-ascii characters
- test.bas - Some quick tests to make sure there are no bugs
- test*.json - Sample json files, for testing
- Internet awesomeness! You may even get a meme named after you!
Sample JSON (test1.json)
Code: Select all
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A \"meta-markup\" language, used to create markup languages such as DocBook.\tTab!\u002e",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}
Code: Select all
dim test as fbJSON ptr = fbJSON_ImportFile( "test1.json" )
if test = NULL then
? "Unable to load json file/string!"
end 1
end if
print fbJSON_ExportString( test, 1 )
fbJSON_Delete( test )
Code: Select all
dim test as fbJSON ptr = fbJSON_ImportFile( "test1.json" )
if test = NULL then
? "Unable to load json file/string!"
end 1
end if
' Output 'example glossary'
print test->childByName("glossary")->childByName("title")->toString()
fbJSON_Delete( test )
Code: Select all
dim test as fbJSON ptr = fbJSON_ImportFile( "test1.json" )
if test = NULL then
? "Unable to load json file/string!"
end 1
end if
' Output 'example glossary'
print test->childByName("glossary")->childByName("title")->asString("changed the title!")
fbJSON_ExportFile( "test1.json", 1 )
fbJSON_Delete( test )
Thanks for the support!
-Oz