且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检查json中的两个数组大小是否相同

更新时间:2022-11-01 13:23:44

否,无法使用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.