save point

This commit is contained in:
kake26 2024-12-12 22:22:08 -06:00
parent ff253ca498
commit fe6be93205
Signed by: kake26
GPG key ID: E8AFC43591876B4D
3 changed files with 24 additions and 6 deletions

BIN
json.db

Binary file not shown.

View file

@ -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

11
jsontest.pb Normal file
View file

@ -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