save point
This commit is contained in:
parent
ff253ca498
commit
fe6be93205
3 changed files with 24 additions and 6 deletions
BIN
json.db
BIN
json.db
Binary file not shown.
19
jsonlib.pb
19
jsonlib.pb
|
@ -1,5 +1,6 @@
|
||||||
UseSQLiteDatabase()
|
UseSQLiteDatabase()
|
||||||
OpenDatabase(0,"json.db","","",#PB_Database_SQLite)
|
OpenDatabase(0,"json.db","","",#PB_Database_SQLite)
|
||||||
|
;TODO:Make sure the database exists
|
||||||
|
|
||||||
Procedure InsertIntoDatabase(key$, parentKey$, type$, value$)
|
Procedure InsertIntoDatabase(key$, parentKey$, type$, value$)
|
||||||
query$ = "INSERT INTO json_data (key, parent_key, type, value) VALUES ('" + 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
|
EndProcedure
|
||||||
|
|
||||||
|
|
||||||
Procedure parse(json)
|
Procedure parse(json.s,filename.s,parentKey$)
|
||||||
; worry about the database init later
|
; 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
|
;LoadJSON(1,"test2.json") ; returns garbage without the PB ascii there not sure why
|
||||||
ParseJSON(1,json)
|
|
||||||
|
|
||||||
ObjectValue = JSONValue(1)
|
ObjectValue = JSONValue(1)
|
||||||
|
|
||||||
|
@ -106,7 +113,7 @@ Procedure parse(json)
|
||||||
|
|
||||||
key$ = JSONMemberKey(ObjectValue)
|
key$ = JSONMemberKey(ObjectValue)
|
||||||
MemberValue = JSONMemberValue(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
|
; Now extract the actual value based on its type
|
||||||
Select JSONType(MemberValue)
|
Select JSONType(MemberValue)
|
||||||
|
@ -149,8 +156,8 @@ Procedure parse(json)
|
||||||
EndIf
|
EndIf
|
||||||
EndProcedure
|
EndProcedure
|
||||||
; IDE Options = PureBasic 6.12 LTS (Linux - x64)
|
; IDE Options = PureBasic 6.12 LTS (Linux - x64)
|
||||||
; CursorPosition = 149
|
; CursorPosition = 115
|
||||||
; FirstLine = 113
|
; FirstLine = 83
|
||||||
; Folding = -
|
; Folding = -
|
||||||
; EnableXP
|
; EnableXP
|
||||||
; DPIAware
|
; DPIAware
|
||||||
|
|
11
jsontest.pb
Normal file
11
jsontest.pb
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue