GitHub
github.com › ijl › orjson
GitHub - ijl/orjson: Fast, correct Python JSON library supporting dataclasses, datetimes, and numpy · GitHub
It benchmarks as the fastest Python library for JSON and is more correct than the standard json library or other third-party libraries. It serializes dataclass, datetime, numpy, and UUID instances natively. orjson.dumps() is something like 10x as fast as json, serializes common types and subtypes, has a default parameter for the caller to specify how to serialize arbitrary types, and has a number of flags controlling output.
Starred by 8K users
Forked by 298 users
Languages Python 52.9% | Rust 46.4% | Shell 0.7%
GitHub
github.com › python › cpython › blob › main › Lib › json › __init__.py
cpython/Lib/json/__init__.py at main · python/cpython
Encoding basic Python object hierarchies:: · >>> import json · >>> json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}]) '["foo", {"bar": ["baz", null, 1.0, 2]}]' >>> print(json.dumps("\"foo\bar")) "\"foo\bar" >>> print(json.dumps('\u1234')) "\u1234" >>> print(json.dumps('\\')) "\\" >>> print(json.dumps({"c": 0, "b": 0, "a": 0}, sort_keys=True)) {"a": 0, "b": 0, "c": 0} >>> from io import StringIO ·
Author python
Videos
05:43
JSON in Python - Part 2 | json.dump() | json.load() - YouTube
09:07
How to use JSON in Python - Part 1 | json.dumps() | json.loads() ...
06:32
JSON Python tutorial: what is JSON and how to parse JSON data with ...
12:29
The Python JSON library .load() and .loads() Methods and Possible ...
18:27
The Python JSON library .dump() and .dumps() Methods and Possible ...
20:34
Python Tutorial: Working with JSON Data using the json Module - ...
Beautiful Soup
tedboy.github.io › python_stdlib › generated › generated › json.dumps.html
json.dumps() — Python Standard Library
Serialize obj to a JSON formatted str. If skipkeys is true then dict keys that are not basic types (str, unicode, int, long, float, bool, None) will be skipped instead of raising a TypeError. If ensure_ascii is false, all non-ASCII characters are not escaped, and the return value may be a unicode instance. See dump ...
GitHub
github.com › simplejson › simplejson
GitHub - simplejson/simplejson: simplejson is a simple, fast, extensible JSON encoder/decoder for Python · GitHub
For those of you that have legacy systems to maintain, there is a very old fork of simplejson in the python2.2 branch that supports Python 2.2. This is based on a very old version of simplejson, is not maintained, and should only be used as a last resort. RawJSON allows embedding pre-encoded JSON strings into output without re-encoding them. This can be useful in advanced cases where JSON content is already serialized and re-encoding would be unnecessary. ... from simplejson import dumps, RawJSON payload = { "status": "ok", "data": RawJSON('{"a": 1, "b": 2}') } print(dumps(payload)) # Output: {"status": "ok", "data": {"a": 1, "b": 2}}
Starred by 1.7K users
Forked by 355 users
Languages Python 61.7% | C 38.3%
Amjadmajid
amjadmajid.github.io › tutorials › JSON_Python.html
Using JSON with Python
1.1 Converting from Python data types to JSON strings using json.dumps()
GitHub
github.com › lubyagin › python-json-dumps
GitHub - lubyagin/python-json-dumps: date, Numeric etc. convert to json-string
@C:\Python27\python.exe datetime-json.py print type(t) # datetime.datetime.now() <type 'datetime.datetime'> > print json.dumps([t],default=serialize) ["2016-01-19T08:30:09.242000"] > print json.loads(s) [u'2016-01-19T08:30:09.242000']
Author lubyagin
GitHub
gist.github.com › keithweaver › ae3c96086d1c439a49896094b5a59ed0
Save JSON file with Python · GitHub
# Save the file import json with open("out.json", "w") as f: json.dump(f, [1, 2, 3]) # r+ is for both reading and writing with open("out.json", "r+") as f: existing_data = json.load(f) # load [1, 2, 3] from the file existing_data.extend([4, 5, 6]) # add [4, 5, 6] to the loaded data json.dump(f, existing_data) # write [1, 2, 3, 4, 5, 6] to the file ·
GitHub
github.com › nanoporetech › sloika › blob › master › bin › dump_json.py
sloika/bin/dump_json.py at master · nanoporetech/sloika
warnings.warn("Support for python 2 pickles will be dropped: {}".format(args.model)) · json_out = model.json(args.params) · if args.out_file is not None: with open(args.out_file, 'w') as f: print("Writing to file: ", args.out_file) json.dump(json_out, f, indent=4, cls=CustomEncoder) else: print(json.dumps(json_out, indent=4, cls=CustomEncoder))
Author nanoporetech
GitHub
gist.github.com › Racum › 7c40e0393c195bc97c41
Guaranteed-order JSON dump in Python using collections.OrderedDict. · GitHub
Guaranteed-order JSON dump in Python using collections.OrderedDict. - guaranteed_order_json.py
GitHub
gist.github.com › jannismain › e96666ca4f059c3e5bc28abb711b5c92
A JSON Encoder in Python, that puts small lists on single lines. · GitHub
$ python3 CompactJSONEncoder.py --example { "compact_object": { "first": "element", "second": 2 }, "compact_list": ["first", "second"], "long_list": [ "this", "is", "a", "rather", "long", "list" ] } ... @keithzg Ahh, I see what the problem is: json.dump works with indent parameters given as int and str, while my encoder assumes and int to multiply my indentation level with.
GitHub
gist.github.com › iancoleman › 4536693
Decimal numbers in python json dump · GitHub
Decimal numbers in python json dump. GitHub Gist: instantly share code, notes, and snippets.
GitHub
gist.github.com › csabahenk › 6527883
Some fun with Python and JSON · GitHub
JSONPickle: a Python module that gives you complete dump Python objects and structures as JSON
Bogotobogo
bogotobogo.com › python › python-json-dumps-loads-file-read-write.php
Python Tutorial: json.dump(s) & json.load(s) - 2024
s()" returns a string as indicated by the "s" at the end of "dumps". This process is called encoding. ... Now that the file is written. Let's reads it back and decoding the JSON-encoded string back into a Python dictionary data structure:
GitHub
github.com › python › cpython › issues › 131884
`json.dump()` with `indent` and `skipkeys` can be formatted incorrectly · Issue #131884 · python/cpython
January 2, 2025 - stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error · nineteendo · opened · on Mar 29, 2025 · Issue body actions · >>> import json >>> print(json.dumps({b"": 0}, indent=4, skipkeys=True)) { } Related: #123183 ·
Author nineteendo
GitHub
gist.github.com › simonw › 7000493
How to use custom Python JSON serializers and deserializers to automatically roundtrip complex types. · GitHub
>>> import json >>> import datetime >>> data = { ... "name": "Silent Bob", ... "dt": datetime.datetime(2013, 11, 11, 10, 40, 32) ... } # Fails as expected >>> json.dumps(data) TypeError: Object of type datetime is not JSON serializable # Succeeds >>> json.dumps(data, default=str) '{"name": "Silent Bob", "dt": "2013-11-11 10:40:32"}'
GitHub
github.com › python › cpython › issues › 129711
json.dump(x,f) is much slower than f.write(json.dumps(x)) · Issue #129711 · python/cpython
December 17, 2024 - extension-modulesC modules in the Modules dirC modules in the Modules dirperformancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error · wjmelements · opened · on Feb 6, 2025 · Issue body actions · Experimentally I measured a huge performance improvement when I switched my code from · json.dump(x, f, **) to ·
Author wjmelements