.. SPDX-FileCopyrightText: 2021 cusy GmbH .. .. SPDX-License-Identifier: BSD-3-Clause JSON ==== Überblick --------- +-----------------------+-------+-------------------------------------------------------+ | Unterstützung von | +- | JSON unterstützt Array- und Map- oder Objectstrukturen| | Datenstrukturen | | vieler verschiedener Datentypen einschließlich | | | | Zeichenfolgen, Zahlen, Boolesche Werte, Null usw., | | | | aber keine Datumsformate. | | | | | | | | Jedoch unterstützt JSON auch nicht alle Datentypen von| | | | JavaScript: ``NaN`` und ``Infinity`` werden zu | | | | ``null``. | | | | | | | | Beachtet auch, dass die JSON keine Kommentare | | | | unterstützt und ihr gegebenenfalls darum herumarbeiten| | | | müsst, z.B. mit einem ``__comment__`` | | | | Schlüssel/Wert-Paar. | +-----------------------+-------+-------------------------------------------------------+ | Standardisierung | \+ | JSON hat einen formal streng typisierten `Standard`_ | | | | siehe auch :rfc:`8259`). | | | | Jedoch enthalten JSON-Daten auch einige Fallstricke | | | | aufgrund der Mehrdeutigkeit der JSON-Specifikationen: | | | | | | | | *Ein JSON-Parser MUSS alle Texte akzeptieren, die der | | | | JSON-Grammatik entsprechen* (:rfc:`7159`). | | | | | | | | und | | | | | | | | *Eine Implementierung kann Grenzen für die Größe der | | | | akzeptierten Texte setzen. Eine Implementierung kann | | | | Grenzen für die maximale Verschachtelungstiefe | | | | festlegen. Eine Implementierung kann Grenzen für den | | | | Bereich und die Genauigkeit von Zahlen festlegen. Eine| | | | Implementierung kann Grenzen für die Länge und den | | | | Zeicheninhalt von Zeichenketten festlegen* | | | | (:rfc:`7158#section-9`). | | | | | | | | Unglücklicherweise gibt es weder eine | | | | Referenzimplementierung noch eine offizielle | | | | Testsuite, die das erwartete Verhalten zeigen würden | | | | – immerhin gibt zumindest `JSON_Checker`_ einige | | | | Hinweise. | +-----------------------+-------+-------------------------------------------------------+ | Schema IDL | +- | Zum Teil mit `JSON Schema Proposal`_, `JSON Encoding | | | | Rules (JER)`_, `Kwalify`_, `Rx`_, `JSON-LD`_ oder | | | | `JMESPath`_. | | | | | | | | Immerhin gibt es viele verschiedene `Validatoren`_. | +-----------------------+-------+-------------------------------------------------------+ | Sprachunterstützung | ++ | Das JSON-Format wird sehr gut von den meisten | | | | Programmiersprachen unterstützt. | | | | | | | | Die Datenstrukturen von JSON sind nahe an den Objekten| | | | der meisten Sprachen, z.B. kann ein Python ``dict`` | | | | einfach als JSON-``object`` und eine Python ``list`` | | | | einfach als JSON-``array`` dargestellt werden. | +-----------------------+-------+-------------------------------------------------------+ | Menschliche Lesbarkeit| +- | JSON ist ein menschlich lesbares | | | | Serialisierungsformat, aber es unterstützt keine | | | | Kommentare. | +-----------------------+-------+-------------------------------------------------------+ | Geschwindigkeit | ++ | JSON ist eines der menschlich lesbaren | | | | Serialisierungsformate, die schnell zu serialisieren | | | | und zu deserialisieren sind. | +-----------------------+-------+-------------------------------------------------------+ | Dateigröße | +- | Die Dateigröße von JSON liegt im Mittelfeld, ähnlich | | | | :doc:`../yaml/index` und :doc:`../toml/index`. | +-----------------------+-------+-------------------------------------------------------+ Beispiel -------- Antwort der :ref:`OSM-Nominatim-API `: .. code-block:: javascript [ { 'place_id': 234847916, 'licence': 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright', 'osm_type': 'relation', 'osm_id': 131761, 'boundingbox': ['52.5200695', '52.5232601', '13.4103097', '13.4160798'], 'lat': '52.521670650000004', 'lon': '13.413278026558228', 'display_name': 'Alexanderplatz, Mitte, Berlin, 10178, Deutschland', 'class': 'highway', 'type': 'pedestrian', 'importance': 0.6914982526373583 }, { 'place_id': 53256307, 'licence': 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright', 'osm_type': 'node', 'osm_id': 4389211800, 'boundingbox': ['52.5231653', '52.5232653', '13.414475', '13.414575'], 'lat': '52.5232153', 'lon': '13.414525', 'display_name': 'Alexanderplatz, Alexanderstraße, Mitte, Berlin, 10178, Deutschland', 'class': 'highway', 'type': 'bus_stop', 'importance': 0.22100000000000003, 'icon': 'https://nominatim.openstreetmap.org/images/mapicons/transport_bus_stop2.p.20.png' }, { 'place_id': 90037579, 'licence': 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright', 'osm_type': 'way', 'osm_id': 23853138, 'boundingbox': ['52.5214702', '52.5217276', '13.4037885', '13.4045026'], 'lat': '52.5215991', 'lon': '13.404112295159964', 'display_name': 'Alexander Plaza, 1, Rosenstraße, Mitte, Berlin, 10178, Deutschland', 'class': 'tourism', 'type': 'hotel', 'importance': 0.11100000000000002, 'icon': 'https://nominatim.openstreetmap.org/images/mapicons/accommodation_hotel2.p.20.png' } ] JSON-Tools ---------- `fx `_ macht JSON durchsuchbar. Dies erleichtert :abbr:`v.a. (vor allem)` die Erkundung von APIs, die große JSON-Blöcke zurückgeben, aber schlecht dokumentiert sind. .. image:: https://raster.shields.io/github/stars/antonmedv/fx :alt: Stars :target: https://github.com/antonmedv/fx .. image:: https://raster.shields.io/github/contributors/antonmedv/fx :alt: Contributors :target: https://github.com/antonmedv/fx/graphs/contributors .. image:: https://raster.shields.io/github/commit-activity/y/antonmedv/fx :alt: Commit activity :target: https://github.com/antonmedv/fx/graphs/commit-activity .. image:: https://raster.shields.io/github/license/antonmedv/fx :alt: Lizenz `gron `_ Terminal JSON viewer & processor .. image:: https://raster.shields.io/github/stars/tomnomnom/gron :alt: Stars :target: https://github.com/tomnomnom/gron .. image:: https://raster.shields.io/github/contributors/tomnomnom/gron :alt: Contributors :target: https://github.com/tomnomnom/gron/graphs/contributors .. image:: https://raster.shields.io/github/commit-activity/y/tomnomnom/gron :alt: Commit activity :target: https://github.com/tomnomnom/gron/graphs/commit-activity .. image:: https://raster.shields.io/github/license/tomnomnom/gron :alt: Lizenz `JC – JSON Convert `_ ist ein CLI-Tool und eine Python-Bibliothek, die die Ausgabe gängiger Befehlszeilentools, Dateitypen und Zeichenfolgen in JSON, :doc:`../yaml/index` oder :doc:`python-basics:types/dicts` konvertiert; dies ermöglicht die Weiterleitung der Ausgabe an Tools wie `jq `_ und vereinfacht Automatisierungsskripte. .. image:: https://raster.shields.io/github/stars/kellyjonbrazil/jc :alt: Stars :target: https://github.com/kellyjonbrazil/jc .. image:: https://raster.shields.io/github/contributors/kellyjonbrazil/jc :alt: Contributors :target: https://github.com/kellyjonbrazil/jc/graphs/contributors .. image:: https://raster.shields.io/github/commit-activity/y/kellyjonbrazil/jc :alt: Commit activity :target: https://github.com/kellyjonbrazil/jc/graphs/commit-activity .. image:: https://raster.shields.io/github/license/kellyjonbrazil/jc :alt: Lizenz `UltraJSON `_ ist ein schneller JSON-Encoder und -Decoder, der in reinem C geschrieben ist und Bindings für Python≥3.9 bietet. .. image:: https://raster.shields.io/github/stars/ultrajson/ultrajson :alt: Stars :target: https://github.com/ultrajson/ultrajson .. image:: https://raster.shields.io/github/contributors/ultrajson/ultrajson :alt: Contributors :target: https://github.com/ultrajson/ultrajson/graphs/contributors .. image:: https://raster.shields.io/github/commit-activity/y/ultrajson/ultrajson :alt: Commit activity :target: https://github.com/ultrajson/ultrajson/graphs/commit-activity .. image:: https://raster.shields.io/github/license/ultrajson/ultrajson :alt: Lizenz `simplejson `_ ist ein einfacher, schneller und erweiterbarer JSON-Encoder/Decoder für Python. .. image:: https://raster.shields.io/github/stars/simplejson/simplejson :alt: Stars :target: https://github.com/simplejson/simplejson .. image:: https://raster.shields.io/github/contributors/simplejson/simplejson :alt: Contributors :target: https://github.com/simplejson/simplejson/graphs/contributors .. image:: https://raster.shields.io/github/commit-activity/y/simplejson/simplejson :alt: Commit activity :target: https://github.com/simplejson/simplejson/graphs/commit-activity .. image:: https://raster.shields.io/github/license/simplejson/simplejson :alt: Lizenz `python-json-patch `_ ist eine Python-Bibliothek für JSON-Patches gemäß :rfc:`6902`. .. image:: https://raster.shields.io/github/stars/stefankoegl/python-json-patch :alt: Stars :target: https://github.com/stefankoegl/python-json-patch .. image:: https://raster.shields.io/github/contributors/stefankoegl/python-json-patch :alt: Contributors :target: https://github.com/stefankoegl/python-json-patch/graphs/contributors .. image:: https://raster.shields.io/github/commit-activity/y/stefankoegl/python-json-patch :alt: Commit activity :target: https://github.com/stefankoegl/python-json-patch/graphs/commit-activity .. image:: https://raster.shields.io/github/license/stefankoegl/python-json-patch :alt: Lizenz `jsonata-python `_ `JSONata `_ ist eine leichtgewichtige Abfrage- und Transformationssprache für JSON-Daten, inspiriert von XPath. .. image:: https://raster.shields.io/github/stars/rayokota/jsonata-python :alt: Stars :target: https://github.com/rayokota/jsonata-python .. image:: https://raster.shields.io/github/contributors/rayokota/jsonata-python :alt: Contributors :target: https://github.com/rayokota/jsonata-python/graphs/contributors .. image:: https://raster.shields.io/github/commit-activity/y/rayokota/jsonata-python :alt: Commit activity :target: https://github.com/rayokota/jsonata-python/graphs/commit-activity .. image:: https://raster.shields.io/github/license/rayokota/jsonata-python :alt: Lizenz .. _`standard`: https://www.json.org/json-en.html .. _`JSON_Checker`: http://www.json.org/JSON_checker/ .. _`JSON Schema Proposal`: https://json-schema.org .. _`JSON Encoding Rules (JER)`: https://www.itu.int/rec/T-REC-X.697-201710-I/ .. _`Kwalify`: http://www.kuwata-lab.com/kwalify/ .. _`Rx`: https://rx.codesimply.com .. _`JSON-LD`: https://json-ld.org# .. _`JMESPath`: https://jmespath.org/ .. _`Validatoren`: https://json-schema.org/tools?query=&sortBy=name&sortOrder=ascending&groupBy=toolingTypes&licenses=&languages=&drafts=&toolingTypes=#validator .. toctree:: :hidden: :titlesonly: :maxdepth: 0 example.ipynb