Skip to content
This repository has been archived by the owner on May 24, 2018. It is now read-only.

phensley/microjson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

About

microjson - A minimal, valid, pure-Python JSON parser/emitter.

Goal was to create something small enough to be embedded into standalone scripts, enabling them to talk to an API which returns JSON data, like Github's, without relying on external dependencies other than the Python standard library.

Github offers multiple encodings, but I prefer the ease of working with JSON over XML; YAML is nice too, though I wasn't interested in writing a YAML parser.

Usage

obj = microjson.from_json(json_data)

json_data = microjson.to_json(obj)

Embedding

I typically write the standalone scripts with this pattern:

def main():
    do_something()

if __name__ == "__main__":
    main()

If and when I need to update microjson, I'll pull down the latest from Github and use a sed command to generate the final script:

% sed -e '/^@MICROJSON@$/ { <return>
    r microjson.py <return>
    d; }' myscript.in >myscript

If you use cat or some other method of embedding microjson.py, make sure the "if __name__ ..." line is at the end of the script.

About

Archived - small json parser for embedding in Python scripts, pre-json module

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages