🌐
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
🌐
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%
🌐
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
github.com › python › cpython › issues › 107544
json.dump(..., default=something) takes a unary function but is documented binary · Issue #107544 · python/cpython
June 4, 2023 - import json def unary(a): raise TypeError("unary") # EXPECTED: TypeError: unary json.dumps({"sample": object()}, default=unary)
Author   RhysU
🌐
GitHub
github.com › mfadliridhani › python-json.dumps-
GitHub - mfadliridhani/python-json.dumps-
Contribute to mfadliridhani/python-json.dumps- development by creating an account on GitHub.
Author   mfadliridhani
🌐
Readthedocs
simplejson.readthedocs.io
simplejson — JSON encoder and decoder — simplejson 3.19.1 ...
It is the externally maintained version of the json library, but maintains compatibility with the latest Python 3.8+ releases back to Python 3.3 as well as the legacy Python 2.5 - Python 2.7 releases. Development of simplejson happens on Github: http://github.com/simplejson/simplejson ...
🌐
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"}'
Find elsewhere
🌐
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 20, 2024 - Bug report Bug description: Experimentally I measured a huge performance improvement when I switched my code from json.dump(x, f, **) to f.write(json.dumps(x, **)) Method I essentially wrote the same contents to different files sequentia...
Author   wjmelements
🌐
GeeksforGeeks
geeksforgeeks.org › python › json-dumps-in-python
json.dumps() in Python - GeeksforGeeks
The json.dumps() function in Python converts a Python object (such as a dictionary or list) into a JSON-formatted string.
Published   March 3, 2020
🌐
Python
docs.python.org › 3 › library › json.html
JSON encoder and decoder — Python 3.14.3 documentation
Serialize obj to a JSON formatted str using this conversion table. The arguments have the same meaning as in dump(). ... Keys in key/value pairs of JSON are always of the type str. When a dictionary is converted into JSON, all the keys of the dictionary are coerced to strings.
🌐
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
github.com › python › cpython › issues › 131884
`json.dump()` with `indent` and `skipkeys` can be formatted incorrectly · Issue #131884 · python/cpython
January 5, 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
github.com › python › cpython › blob › main › Lib › json › encoder.py
cpython/Lib/json/encoder.py at main · python/cpython
| Python | JSON | +===================+===============+ | dict, frozendict | object | +-------------------+---------------+ | list, tuple | array | +-------------------+---------------+ | str | string | +-------------------+---------------+ | int, float | number | +-------------------+---------------+ | True | true | +-------------------+---------------+ | False | false | +-------------------+---------------+ | None | null | +-------------------+---------------+ ·
Author   python
🌐
GitHub
github.com › mangiucugna › json_repair
GitHub - mangiucugna/json_repair: A python module to repair invalid JSON from LLMs · GitHub
More in general, repair_json will accept all parameters that json.dumps accepts and just pass them through (for example indent)
Starred by 4.6K users
Forked by 175 users
Languages   Python
🌐
GitHub
github.com › python › cpython › issues › 91114
json dump/dumps: support printing arrays on a single line · Issue #91114 · python/cpython
January 5, 2022 - 3.13bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement ... gh-91114: Added argument for json dump/dumps to print arrays (from lists and tuples) on one line #31762
Author   dmarshall-bing
🌐
GitHub
github.com › jupyter › notebook › issues › 5926
JSON.dumps() creates invalid JSON with single quote · Issue #5926 · jupyter/notebook
August 26, 2020 - Describe the bug JSON.dumps() creates invalid JSON with single quote the JSON.dumps() function should create valid JSON using double quotes only, however when the function is run with an object as its argument it results in invalid JSON using ...
Author   psuhas20