在SQL Server中查找JSON架构 [英] Find JSON Schema in SQL Server

查看:158
本文介绍了在SQL Server中查找JSON架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个字段中有JSON,但是在处理它之前,我需要检查它的架构.我需要知道是否已从架构中添加或删除了任何内容.

I have JSON in a field, but I need to check it's schema before I process it. I need to know if anything has been added or removed from the schema.

是否可以从JSON字符串中提取JSON模式,以便将其与已知模式进行比较?

Is there a way to extract the JSON schema from a JSON string so I can compare it to a known schema?

一个在线示例是 http://jsonschema.net/,但是我想在TSQL中做同样的事情

An online example is http://jsonschema.net/, but I want to do the same thing in TSQL

推荐答案

SQL Server不支持任何json模式绑定.

SQL Server don't support any json schema binding.

如果您的JSON是简单或扁平的,则可以使用

If your JSON is simple or flat, you can use

SELECT [key] FROM OPENJSON(@json)

查找第一级上的所有键,并将它们与一些预期的键集进行比较.

to find all keys on the first level and compare them with some expected key set.

这篇关于在SQL Server中查找JSON架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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