From 9cb5c91e7e42bce358abf625a85619ed54e3d50f Mon Sep 17 00:00:00 2001 From: kake26 Date: Sat, 9 Nov 2024 20:57:45 -0600 Subject: [PATCH] save point --- json.db | Bin 0 -> 12288 bytes jsonlib copy.pb | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ jsonlib.pb | 64 ++++++++++++++++++++++++++++++++++++++++++++++ results.json | 1 + 4 files changed, 131 insertions(+) create mode 100644 json.db create mode 100644 jsonlib copy.pb create mode 100644 jsonlib.pb create mode 100644 results.json diff --git a/json.db b/json.db new file mode 100644 index 0000000000000000000000000000000000000000..85641e427ff942c0338bcec55643248f94ec8872 GIT binary patch literal 12288 zcmeI#F;Buk6bJCTVl*KUTpC8+W=V>JhQZBBP9>tzv#7X`Dp##SOUh}&sNc=+EiE3=9D^M(Ak z)Mi`!X5Cb+(g!QQn-2m45P$##AOHafKmY;|fB*y_@DBp7(psxjtNd-OgWG|694B$F zALwA76q-_az98S*Zws0)lT#!UQJ-3;zBm+;&SdMvlU+I%T{o{isR{Yw+MmuwL8@Zi z%ND;+xJ30j9VDrW?qkXdsS1_Zb*D%tq#qPb50N>TPF#vYiq%-Fetx~4jMT#YFTvn> zIxp6C`D(?s`BmOh6o*MRtRIbJE97W%9bI~|dE`lFyV0oCvbVW;^dleu0SG_<0uX=z z1Rwwb2tWV=5LjY?+55ljl$}zi)LG(I(HaCG009U<00Izz00bZa0SG{VvCrj0*!)9F EUu;fX(EtDd literal 0 HcmV?d00001 diff --git a/jsonlib copy.pb b/jsonlib copy.pb new file mode 100644 index 0000000..d419660 --- /dev/null +++ b/jsonlib copy.pb @@ -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 \ No newline at end of file diff --git a/jsonlib.pb b/jsonlib.pb new file mode 100644 index 0000000..0271e72 --- /dev/null +++ b/jsonlib.pb @@ -0,0 +1,64 @@ +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) + + key$ = JSONMemberKey(ObjectValue) + MemberValue = JSONMemberValue(ObjectValue) + parentKey$ = "" ; Assuming no parent key information is available in the current code. + + ; Now extract the actual value based on its type + 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))) ;Feels cheaty, but it workssss + type$ = "Boolean" + + Case #PB_JSON_Object + value$ = "(nested object)" + ;Debug key$ + parentKey$ = key$ + type$ = "object" + ; You could further examine this nested object if needed. + + 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 ('" + key$ + "', '" + parentKey$ + "', '" + type$ + "', '" + value$ + "')" + If DatabaseUpdate(0, query$) = 0 + Debug "Error inserting data: " + DatabaseError() + EndIf + + Wend +EndIf +; IDE Options = PureBasic 6.12 LTS (Linux - x64) +; CursorPosition = 37 +; FirstLine = 15 +; EnableXP +; DPIAware \ No newline at end of file diff --git a/results.json b/results.json new file mode 100644 index 0000000..52f90d6 --- /dev/null +++ b/results.json @@ -0,0 +1 @@ +{"admin":{"email":"offal@pngpst.net","created":"2024-07-23 01:32:58.983Z","avatar":0,"updated":"2024-07-23 01:32:58.983Z","id":"xf9w05ts29nik6z"},"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzIzNDUwMjIsImlkIjoieGY5dzA1dHMyOW5pazZ6IiwidHlwZSI6ImFkbWluIn0.UM_QP4NVBdioMLU8mPJ9ZL0bq_ylLPQ6Jdn3AzNKjK0"} \ No newline at end of file