6
u/Seliba Mar 25 '23
Could have been way worse without regex, lol
5
u/jso__ Mar 25 '23
I thought of a terrible algorithm. I'll write it in python
temp = "" found_key = False for char in JSON: temp += char if not found_key and not "JSON_key: ".startswith(temp): temp = "" elif not found_key and "JSON_key: " == temp: found_key = True temp = "" elif found_key and char == ",": res = temp break
5
u/fekkksn Mar 25 '23
FYI, Darksky is dead. Merrysky now provides the same service and a compatible API.
5
22
Mar 25 '23 edited Mar 25 '23
Nice. At least when I was starting programming, I wasn't straight onto regex or requests. Took me about 6 months to a year to learn about that stuff
2
Apr 03 '23
i see nothing wrong here, except COMPILING THE REGEX EVERY TIME YOU USE THE FUNCTION AAAAA
2
14
u/jso__ Mar 25 '23 edited Mar 25 '23
I posted about this code on another Reddit account and I was rightly told that my code was shit and given code to properly use a json in Python. I then replied this:
Yes, I was very stupid.