检查json中的两个数组大小是否相同 [英] Check that two arrays in json have the same size

查看:71
本文介绍了检查json中的两个数组大小是否相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用json架构以某种方式验证一个json中的两个数组具有相同的大小吗?可能有某种方法可以将变量用于maxItems和minItems?

Can I somehow validate that two arrays in one json have the same size using json schema? May be there is some way to use variable for maxItems and minItems?

推荐答案

否,无法使用JSON模式执行此操作.这将需要从实例的一部分读取数据,并使用该数据来验证实例的另一部分.有

No, there is no way to do this with JSON Schema. This would require reading data from one part of the instance and using that to validate another part of the instance. There is a lot of discussion around this, but the team has been focused on other requested features lately.

我建议您仅检查数组的长度.您没有提到正在使用什么系统/语言,但是我敢肯定您的本地JSON库应该能够很简单地为您提供该信息.

I would suggest that you simply check the length of the arrays. You don't mention what system/language you're using, but I'm sure that your local JSON library should be able to give you that info pretty simply.

这篇关于检查json中的两个数组大小是否相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆