Consuming JSON Strings in SQL Server

This article describes a TSQL JSON parser and its evil twin, a JSON outputter, and provides the source. It is also designed to illustrate a number of string manipulation techniques in TSQL. With it you can do things like this to extract the data from a JSON document: 

 Select * from parseJSON('{

  "Person":

  {

     "firstName": "John",

     "lastName": "Smith",

     "age": 25,

     "Address":

     {

        "streetAddress":"21 2nd Street",

        "city":"New York",

        "state":"NY",

        "postalCode":"10021"

     },

     "PhoneNumbers":

     {

        "home":"212 555-1234",

        "fax":"646 555-4567"

     }

  }

}

')