Skip to content
The Chat Archive
gpt-3.5-turbo-0613· OpenAI WildChat-4.8M (AI2)

举一个把json转化成yaml的例子,内容关于书籍

  1. User

    举一个把json转化成yaml的例子,内容关于书籍

  2. Assistant

    以下是一个将JSON转换为YAML的示例,内容为书籍信息:

    JSON输入:

    {
      "books": [
        {
          "title": "The Great Gatsby",
          "author": "F. Scott Fitzgerald",
          "year": 1925
        },
        {
          "title": "To Kill a Mockingbird",
          "author": "Harper Lee",
          "year": 1960
        },
        {
          "title": "Pride and Prejudice",
          "author": "Jane Austen",
          "year": 1813
        }
      ]
    }
    

    YAML输出:

    books:
    - title: The Great Gatsby
      author: F. Scott Fitzgerald
      year: 1925
    - title: To Kill a Mockingbird
      author: Harper Lee
      year: 1960
    - title: Pride and Prejudice
      author: Jane Austen
      year: 1813
    

    以上示例将包含书籍信息的JSON转换为了相应的YAML格式。每本书都表示为一个包含标题、作者和年份的对象。在YAML中,每本书被表示为一个带有标题、作者和年份的列表项。