Clean up for release

This commit is contained in:
kake26 2024-12-14 22:51:44 -06:00
parent fe6be93205
commit 4c6e9ecc65
Signed by: kake26
GPG key ID: E8AFC43591876B4D
12 changed files with 0 additions and 3 deletions

66
variants/jsonlib copy.pb Executable file
View file

@ -0,0 +1,66 @@
UseSQLiteDatabase()
; worry about the database init later
OpenDatabase(0,"json.db","","",#PB_Database_SQLite)
LoadJSON(1,"results.json");ParseJSON(1, json$) ; returns garbage without the PB ascii there not sure why
ParseJSON(1, json$) ; returns garbage without the PB ascii there not sure why
ObjectValue = JSONValue(1)
If ExamineJSONMembers(ObjectValue)
While NextJSONMember(ObjectValue)
Debug "Key: " + JSONMemberKey(ObjectValue)
MemberValue = JSONMemberValue(ObjectValue)
; Now extract the actual value based on its type
Select JSONType(MemberValue)
Case #PB_JSON_String
Debug "Value (String): " + GetJSONString(MemberValue)
Case #PB_JSON_Number
Debug "Value (Number): " + StrD(GetJSONDouble(MemberValue))
Case #PB_JSON_Boolean
Debug "Value (Boolean): " + Bool(GetJSONBoolean(MemberValue))
Case #PB_JSON_Object
Debug "Value (Object): (nested object)"
; You could further examine this nested object if needed.
Case #PB_JSON_Array
Debug "Value (Array): (nested array)"
; Handle array values if needed.
Default
Debug "Value (Unknown type)"
EndSelect
Wend
endif
; IDE Options = PureBasic 6.12 LTS (Linux - x64)
; CursorPosition = 43
; FirstLine = 33
; Folding = -
; EnableXP
; DPIAware
; IDE Options = PureBasic 6.12 LTS (Linux - x64)
; CursorPosition = 9
; EnableXP
; DPIAware

97
variants/jsonlib2.pb Executable file
View file

@ -0,0 +1,97 @@
UseSQLiteDatabase()
Procedure searchkey()
searchKey$ = "your.key.path"
query$ = "SELECT * FROM json_data WHERE key = '" + searchKey$ + "'"
If DatabaseQuery(0, query$)
While NextDatabaseRow(0)
Debug "Key: " + GetDatabaseString(0, 0)
Debug "Parent Key: " + GetDatabaseString(0, 1)
Debug "Type: " + GetDatabaseString(0, 2)
Debug "Value: " + GetDatabaseString(0, 3)
Wend
FinishDatabaseQuery(0)
Else
Debug "Error executing query: " + DatabaseError()
EndIf
EndProcedure
Procedure searchval()
searchValue$ = "specific value"
query$ = "SELECT * FROM json_data WHERE value = '" + searchValue$ + "'"
If DatabaseQuery(0, query$)
While NextDatabaseRow(0)
Debug "Key: " + GetDatabaseString(0, 0)
Debug "Parent Key: " + GetDatabaseString(0, 1)
Debug "Type: " + GetDatabaseString(0, 2)
Debug "Value: " + GetDatabaseString(0, 3)
Wend
FinishDatabaseQuery(0)
Else
Debug "Error executing query: " + DatabaseError()
EndIf
EndProcedure
Procedure ProcessJSONObject(ObjectValue, parentKey$)
If ExamineJSONMembers(ObjectValue)
While NextJSONMember(ObjectValue)
key$ = JSONMemberKey(ObjectValue)
MemberValue = JSONMemberValue(ObjectValue)
fullKey$ = parentKey$ + key$
Select JSONType(MemberValue)
Case #PB_JSON_String
value$ = GetJSONString(MemberValue)
type$ = "String"
Case #PB_JSON_Number
value$ = StrD(GetJSONDouble(MemberValue))
type$ = "Number"
Case #PB_JSON_Boolean
value$ = Str(Bool(GetJSONBoolean(MemberValue)))
type$ = "Boolean"
Case #PB_JSON_Object
value$ = "(nested object)"
type$ = "Object"
; Recursively process the nested object
ProcessJSONObject(MemberValue, fullKey$ + ".")
Case #PB_JSON_Array
value$ = "(nested array)"
type$ = "Array"
; Handle array values if needed.
Default
value$ = "(unknown type)"
type$ = "Unknown"
EndSelect
; Insert the parsed data into the SQLite database
query$ = "INSERT INTO json_data (key, parent_key, type, value) VALUES ('" + fullKey$ + "', '" + parentKey$ + "', '" + type$ + "', '" + value$ + "')"
If DatabaseUpdate(0, query$) = 0
Debug "Error inserting data: " + DatabaseError()
EndIf
Wend
EndIf
EndProcedure
OpenDatabase(0, "json.db", "", "", #PB_Database_SQLite)
LoadJSON(1, "results.json")
ParseJSON(1, json$) ; returns garbage without the PB ascii there not sure why
ObjectValue = JSONValue(1)
ProcessJSONObject(ObjectValue, "")
; IDE Options = PureBasic 6.12 LTS (Linux - x64)
; CursorPosition = 37
; FirstLine = 11
; Folding = -
; EnableXP
; DPIAware

11
variants/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