diff --git a/json.db b/json.db index e484fc9..1fa51c4 100755 Binary files a/json.db and b/json.db differ diff --git a/jsonlib.pb b/jsonlib.pb index 7fbf1c2..0f10fbb 100755 --- a/jsonlib.pb +++ b/jsonlib.pb @@ -1,5 +1,6 @@ UseSQLiteDatabase() OpenDatabase(0,"json.db","","",#PB_Database_SQLite) +;TODO:Make sure the database exists Procedure InsertIntoDatabase(key$, parentKey$, type$, value$) query$ = "INSERT INTO json_data (key, parent_key, type, value) VALUES ('" + key$ + "', '" + parentKey$ + "', '" + type$ + "', '" + value$ + "')" @@ -91,13 +92,19 @@ Procedure HandleNestedArray(JSONValue, parentKey$) EndProcedure -Procedure parse(json) +Procedure parse(json.s,filename.s,parentKey$) ; worry about the database init later + If json.s + ParseJSON(1,json.s) + EndIf + + If filename.s + LoadJSON(1,filename.s) + EndIf - ;LoadJSON(1,"test2.json") ; returns garbage without the PB ascii there not sure why - ParseJSON(1,json) + ObjectValue = JSONValue(1) @@ -106,7 +113,7 @@ Procedure parse(json) key$ = JSONMemberKey(ObjectValue) MemberValue = JSONMemberValue(ObjectValue) - parentKey$ = "" ; Assuming no parent key information is available in the current code. + ;parentKey$ = "" ; Assuming no parent key information is available in the current code. ; Now extract the actual value based on its type Select JSONType(MemberValue) @@ -149,8 +156,8 @@ Procedure parse(json) EndIf EndProcedure ; IDE Options = PureBasic 6.12 LTS (Linux - x64) -; CursorPosition = 149 -; FirstLine = 113 +; CursorPosition = 115 +; FirstLine = 83 ; Folding = - ; EnableXP ; DPIAware diff --git a/jsontest.pb b/jsontest.pb new file mode 100644 index 0000000..3ccaf82 --- /dev/null +++ b/jsontest.pb @@ -0,0 +1,11 @@ +; library test code + +XIncludeFile "jsonlib.pb" + +parse("","test2.json") + + +; IDE Options = PureBasic 6.12 LTS (Linux - x64) +; CursorPosition = 6 +; EnableXP +; DPIAware \ No newline at end of file