Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 数字的MaxLength的JSON架构属性_C#_Json_Json.net_Jsonschema - Fatal编程技术网

C# 数字的MaxLength的JSON架构属性

C# 数字的MaxLength的JSON架构属性,c#,json,json.net,jsonschema,C#,Json,Json.net,Jsonschema,我需要限制十进制类型的金额字段的长度为12+4。i、 例如,最大整数值可以是9999999999,而小数位数的最大值是4。我正在使用NewtonSoft.JSON进行模式验证 我尝试使用下面的模式,但它似乎不起作用 { "type":"object", "required":false, "properties":{ "Product": { "type":"object", "require

我需要限制十进制类型的金额字段的长度为12+4。i、 例如,最大整数值可以是9999999999,而小数位数的最大值是4。我正在使用NewtonSoft.JSON进行模式验证

我尝试使用下面的模式,但它似乎不起作用

    {
    "type":"object",    
    "required":false,
    "properties":{
        "Product": {
            "type":"object",
            "required":false,
            "properties":{
                "Amount": {
                    "type":"number",
                    "required":true, 
                    "blank":false, 
                    "minLength":1, 
                    "maxDecimal":4 , 
                    "minimum":0, 
                    "maximum": 999999999999
                },
                "ProductID": {
                    "type":"string",
                    "required":false
                },
                "ProductType": {
                    "type":"string",
                    "required":false
                }
            }
        }
    }
}
有人能带我到这里吗。提前谢谢

我的输入JSON字符串如下所示

{
  "Product": {
    "Amount": 888888888888.2222,
    "ProductType": "Notes",
    "ProductID": "GBPN"
  }
}
从Json模式文档:

3.2。数字实例的验证

JSON规范没有定义数值的比例或精度的任何界限。JSON模式也没有定义任何这样的界限。这意味着由JSON模式处理的数字实例可以任意大和/或具有任意大的小数部分,而不管底层编程语言处理此类数据的能力如何


您需要为此开发自定义验证。请注意,Json.Net使用Json模式draft3

您的JSON数据格式不正确。我刚刚从模式中摘录了一段内容。现在编辑问题以提供完整的模式。