JSON#
Überblick#
Unterstützung von Datenstrukturen |
+- |
JSON unterstützt Array- und Map- oder Objectstrukturen vieler verschiedener Datentypen einschließlich Zeichenfolgen, Zahlen, Boolesche Werte, Null usw., aber keine Datumsformate. Jedoch unterstützt JSON auch nicht alle Datentypen von
JavaScript: Bitte beachtet auch, dass die JSON keine Kommentare
unterstützt und ihr gegebenenfalls darum herumarbeiten
müsst, z.B. mit einem |
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: A JSON parser MUST accept all texts that conform to the JSON grammar (RFC 7159) und An implementation may set limits on the size of texts that it accepts. An implementation may set limits on the maximum depth of nesting. An implementation may set limits on the range and precision of numbers. An implementation may set limits on the length and character contents of strings (RFC 7158 #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 |
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 YAML und TOML. |
Beispiel#
Antwort der OSM-Nomination-API:
[
{
'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'
}
]