Skip to content

Instantly share code, notes, and snippets.

View iqdavidh's full-sized avatar

david huerta iqdavidh

  • parallax.mx
  • CDMX
View GitHub Profile
<?php
/**
* Copyright (c) 2017 Edgar Merino
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@puleos
puleos / JSON-TSQL.sql
Created March 18, 2011 23:22
Json Parse Functions for MS SQL (by Phil Factor)
IF OBJECT_ID (N'dbo.parseJSON') IS NOT NULL
DROP FUNCTION dbo.parseJSON
GO
CREATE FUNCTION dbo.parseJSON( @JSON NVARCHAR(MAX))
RETURNS @hierarchy TABLE
(
element_id INT IDENTITY(1, 1) NOT NULL, /* internal surrogate primary key gives the order of parsing and the list order */
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 from the document */
Object_ID INT,/* each list or object has an object id. This ties all elements to a parent. Lists are treated as objects here */