The Create FUNCTION [dbo] [parseJSON] (@ JSON NVARCHAR (MAX))
RETURNS the @ hierarchy TABLE
(
Element_id INT IDENTITY (1, 1) NOT NULL,/* internal surrogate primary key gives the order of parsing and the list order */
SequenceNo [int] NULL,/* the place in the sequence for the element */
Parent_ID INT,/* if the element has a parent then it is in this column. The document is the ultimate parent, so you can get the structure from recursing the from the document */
Object_ID INT,/* each list or object has an object id. This ties all elements to a parent. The Lists are treated as objects here */
The NAME NVARCHAR (2000), the NAME of the object *//*
StringValue NVARCHAR (MAX) is NOT NULL,/* the string representation of the value of the element. */
ValueType VARCHAR (10) NOT null/* the declared type of the value represented as a string in StringValue */
)
AS