【问题标题】:NodeJS - JSON Source Data File to Different SchemaNodeJS - 不同模式的 JSON 源数据文件
【发布时间】:2019-08-07 18:31:01
【问题描述】:

需要将源 JSON 数据文件转换为不同的 JSON 架构格式。有几百个字段,所以我希望能够将源字段映射到目标。有什么想法吗?

源样本:

[  {
     orderNumber: 123,
     orderItemStatusTypeId: "OPEN",
     showInCatalog: TRUE
     usedOrderTicketNumber: "A232PQ"
   },
   ...
 ]

目标架构:

Orders:
    type: array,
    items:
        Order: 
            title: order
            type: object
            properties:
            orderItemId:
                type: integer
                description: >-  
                    Source field is - `orderNumber`
                format: int64
            statusTypeId:
                type: string
                description: >-
                Source field is - `orderItemStatusTypeId`
            isShowInCatalog:
                type: boolean
                description: >-
                Source field is - `showInCatalog`
            ticketNumber:
                type: string
                description: >-
                Source field is - `usedOrderTicketNumber`

【问题讨论】:

    标签: node.js json schema


    【解决方案1】:

    我最终使用了模块“flat”。所有人都知道的一件事,适用于运行 > 10 的 ES6 节点应用程序。但是,当针对 trireme 运行时,需要针对数据输入进行广泛的数据验证,而不是您已经不会这样做。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-13
      • 1970-01-01
      • 1970-01-01
      • 2019-04-04
      • 1970-01-01
      • 2019-08-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多