Skip to content

georgetsouvaltzis/json-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 

Repository files navigation

JSON Parser in Python with zero dependencies.

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)

Example usage:

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 }

About

Scratch implementation of JSON parser in Python without RegEx

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages