armd/mapping

该软件包最新版本(dev-main)没有可用的许可证信息。

使用YAML配置文件将json或xml文件或API映射

dev-main 2022-11-11 16:13 UTC

This package is auto-updated.

Last update: 2024-09-11 20:04:50 UTC


README

使用YAML配置文件将JSON或XML文件或API映射

安装方法

composer require armd/mapping

使用方法

如果你有一个如下所示的JSON文件,并且你想将“products”键更改为“merchandise”,同时你想将第一个产品的“description”键更改为“details”

{
    "products": [
        {
            "id": 1,
            "title": "iPhone 9",
            "description": "An apple mobile which is nothing like apple",
            "price": 549,
            "discountPercentage": 12.96,
            "rating": 4.69,
            "stock": 94,
            "brand": "Apple",
            "category": "smartphones",
            "thumbnail": "https://dummyjson.com/image/i/products/1/thumbnail.jpg",
            "images": [
                "https://dummyjson.com/image/i/products/1/1.jpg",
                "https://dummyjson.com/image/i/products/1/2.jpg",
                "https://dummyjson.com/image/i/products/1/3.jpg",
                "https://dummyjson.com/image/i/products/1/4.jpg",
                "https://dummyjson.com/image/i/products/1/thumbnail.jpg"
            ]
        }
    ],
    "total": 100,
    "skip": 0,
    "limit": 30
}

你应该这样写你的YAML文件

products: 
  value: "merchendise"
  child: 
    0:
      child:
        description:
          value: "details"