Find JSON Schema in SQL Server

℡╲_俬逩灬. 提交于 2019-12-11 06:56:55

问题


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.

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

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


回答1:


SQL Server don't support any json schema binding.

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.



来源:https://stackoverflow.com/questions/39652524/find-json-schema-in-sql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!