:: krowemoh

Friday | 27 DEC 2024
Posts Links Other About Now

previous
next

Writing JSON.PARSE - 1

2023-03-26

I wrote a JSON.PARSE function in BASIC. Quite fun and took a hot second. I wrote the function such that it returns back a nested multivalue set of data that you can use to LOCATE. This means that it isn't trying to do anything funny with the data as I did think about trying to keep it Multivalue focused.

The function is light but recursive and I'm hoping it is correct. I tested against a few different JSON api examples and it all seems to be working properly. My biggest problem is that I have two LOWER commands when the recursion hits. I feel like it should be just a single lower but it doesn't work with just one. For now I'm going to use it but I will need to figure out what exactly is happening.

I want to write a jq style function as well so that I can give a path instead having to traversing the path myself.

I also have to deal with the depth of the parsed JSON. I'm pretty sure I have a limit of 3 levels and it seems to be proven by some testing. I think if I write a LOWER and RAISE function that can go deeper than STM, I will have a decent parser. It will be slow but useable.

It does mean my parser has a limit of how deep it can find keys.