From 8434e9f643a05e8df85e4af18a2c2f26b1c75d80 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Wed, 20 Sep 2023 15:11:52 -0500 Subject: [PATCH] Add 'jsonparser_pseudo' --- jsonparser_pseudo | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 jsonparser_pseudo diff --git a/jsonparser_pseudo b/jsonparser_pseudo new file mode 100644 index 0000000..c622b12 --- /dev/null +++ b/jsonparser_pseudo @@ -0,0 +1,26 @@ +originalString is a string containing all the data from a JSON file ready to be parsed. + + +Define ReadJSON(originalString): +Iterate through al l characters of originalString as index i: + +First find '{', this is the opening brace for any given JSON object. +Allocate memory for our new JSONDocument object. Set pointer to result +Read characters until a '"' is found. This is the start of a key. +Find the next '"' that is not preceded by '\' (escape characters should ignore the next character). This is the end of a key. +Store the key name in a variable called key without the quotation marks. +Next find the colon ':' character. +Now read until a non-whitespace character (ignore \t, ' ', and \n) is found. + +If it's a { then we found another JSON object: + Set start to i. + Set a nesting counter to 0. + Iterate through all characters of originalString continuing from index i as index i: + As we search, if we find a '{': + Increment nesting by 1. + As we search, if we find a '}': + If nesting == 0: + Call ReadJSON( originalString.substr(start, i) ) + else: + Decrement nesting by 1. +