【问题标题】:How to display json schema using Dataweave in Mule 4?如何在 Mule 4 中使用 Dataweave 显示 json 模式?
【发布时间】:2019-09-23 06:06:21
【问题描述】:

在 Mule 4 中,我只想使用 DataWeave 显示 JSONschema,但在 JSON 模式中引用 ID 或任何以“$”开头的字段时出现错误。 mime/类型是应用程序/json。目标是显示架构,我将不胜感激任何建议。谢谢!

示例架构

{
  "definitions": {},
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "http://example.com/example.json",
  "type": "object",
  "title": "The Root Schema",
  "properties": {
    "checked": {
      "$id": "/properties/checked",
      "type": "boolean",
      "title": "The Checked Schema",
      "default": false,
      "examples": [
        false
      ]
    },
    "dimensions": {
      "$id": "/properties/dimensions",
      "type": "object",
      "title": "The Dimensions Schema",
      "required": [
        "width",
        "height"
      ],
      "properties": {
        "width": {
          "$id": "/properties/dimensions/properties/width",
          "type": "integer",
          "title": "The Width Schema",
          "default": 0,
          "examples": [
            5
          ]
        },
        "height": {
          "$id": "/properties/dimensions/properties/height",
          "type": "integer",
          "title": "The Height Schema",
          "default": 0,
          "examples": [
            10
          ]
        }
      }
    },
    "id": {
      "$id": "/properties/id",
      "type": "integer",
      "title": "The Id Schema",
      "default": 0,
      "examples": [
        1
      ]
    }
  }
}

【问题讨论】:

    标签: anypoint-studio mule4


    【解决方案1】:

    在 $ 之前使用黑斜线 \,这将在列名中使用 $ 打印您的架构。不幸的是,作为前缀的 $ 在 Mule 中不被视为字符串的一部分

    例子

    "\$id": "/properties/dimensions/properties/width"

    将打印

    "$id": "/properties/dimensions/properties/width"
    

    【讨论】:

      猜你喜欢
      • 2021-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多