Preserve JSON key order in YAML, refs #1153

pull/2099/head
Simon Willison 2023-07-08 10:26:50 -07:00
rodzic 38fcc96e67
commit 0183e1a72d
2 zmienionych plików z 2 dodań i 2 usunięć

Wyświetl plik

@ -30,12 +30,12 @@ Your ``metadata.yaml`` file can look something like this:
.. code-block:: yaml
title: Custom title for your index page
description: Some description text can go here
license: ODbL
license_url: https://opendatacommons.org/licenses/odbl/
source: Original Data Source
source_url: http://example.com/
title: Custom title for your index page
.. tab:: JSON

Wyświetl plik

@ -6,7 +6,7 @@ import yaml
def metadata_example(cog, example):
cog.out("\n.. tab:: YAML\n\n")
cog.out(" .. code-block:: yaml\n\n")
cog.out(textwrap.indent(yaml.dump(example), " "))
cog.out(textwrap.indent(yaml.safe_dump(example, sort_keys=False), " "))
cog.out("\n\n.. tab:: JSON\n\n")
cog.out(" .. code-block:: json\n\n")
cog.out(textwrap.indent(json.dumps(example, indent=2), " "))