this project implements a simple JSON parser from scratch using Python without any extra dependencies and without any RegEx (just plain iteration)
Parser is currently capable of parsing:
- Strings
- Numbers (int/float and scientific ontations)
- Objects (
{}) - Arrays (
[]) - null/false/true equivalents (
None,False,True) - Basic escape characters (
\\,\"and\n)
from json_parser import JsonParser
json_string = '''
{
"hello": "world",
"age": 25,
"pi": 3.14,
"active": true,
"data": null,
"languages": ["Python", "JavaScript", "Go"],
"nested": {
"a": 1,
"b": [1, 2, 3],
"c": { "x": -4e-3 }
}
}
'''
parser = JsonParser(json_string)
parsed = parser.parse()
print(parsed["hello"]) # "world"
print(parsed["age"]) # 25
print(parsed["nested"]["c"]) # { "x": -0.004 }