From fe6be932050b957080f7b7bae581c3033bbfe38a Mon Sep 17 00:00:00 2001 From: kake26 Date: Thu, 12 Dec 2024 22:22:08 -0600 Subject: [PATCH] save point --- json.db | Bin 20480 -> 20480 bytes jsonlib.pb | 19 +++++++++++++------ jsontest.pb | 11 +++++++++++ 3 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 jsontest.pb diff --git a/json.db b/json.db index e484fc91319177556d10ad86c2da957268a4b766..1fa51c48d5ebaf8cb3de82b93e75ebb268962444 100755 GIT binary patch delta 105 zcmZozz}T>Wae_3X-$WT_M!$^-E99LxUr-7s3n(~k?oo*0WRX{7W7zygQ$!5_{Y@&o delta 46 zcmZozz}T>Wae_1>*F+g-My`zsE955!DA-I+P|yKlnaw>4F`O(63~Umc-)M@c0RT(_ B4PgKP 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