SkillAgentSearch skills...

Microjson

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

Install / Use

/learn @phensley/Microjson
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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.

Related Skills

View on GitHub
GitHub Stars6
CategoryDevelopment
Updated3y ago
Forks2

Languages

Python

Security Score

55/100

Audited on Jan 28, 2023

No findings