使用 json-forms 生成你的配置

在使用 json 格式存储配置的时候,总是需要在管理后台写一堆代码,去校验参数是否合法,防止用户乱写。

最近发现了一个超级好用的工具,可以把开发人员从这个繁琐的工作中解脱出来。

那就是 json-forms,可以使用 json schema 自动生成表单,方便的一塌糊涂。

这是它的demo地址


http://brutusin.org/json-forms/

示例 json schema 代码


{

    "$schema": "http://json-schema.org/draft-03/schema#",
    "type": "object",
    "properties": {
        "species": {
            "title": "Species supported",
            "description": "Changes in this property (`$.species`) trigger the resolution of the actual (depending on the values being selected) schema of a dependent property (`$.subspecies`)",
            "type": "string",
            "enum": [
                "human",
                "dog",
                "cat"
            ],
            "required": true
        },
        "subspecies": {
            "dependsOn": [
                "species"
            ]
        }
    }
}

表单截图

json-forms

这是两个在线工具,可以直接将 json 转成 json schema

http://yapi.demo.qunar.com/editor/  # 推荐 
https://jsonschema.net/

我们只需要将 json-forms 嵌入到我们的代码中,就可以使用这个简单高效的工具了。

更多架构、PHP、GO相关踩坑实践技巧请关注我的公众号:PHP架构师

转载于:https://my.oschina.net/u/222608/blog/1934514

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值