News for hackers. Stuff that matters.
Re:JSON Support in SQL Server 2016 by biot on Monday May 18, 2015 @11:54PM (#9568063)
If I'm reading this correctly, the unfortunate part about using nvarchar rather than a native JSON data type is that it's entirely possible to store malformed JSON into the database, thus putting the responsibility for validation on your business logic. When querying, you need to exclude malformed JSON by using the ISJSON() operator.

I get the argument that nvarchar makes it work with all tooling, but one could make the argument that if your tools don't support JSON already then perhaps they need to get with the times.

Imagine if SQL Server didn't have any date types and you had to query an nvarchar data type with ISDATETIME() and then get the year via DATE_VALUE(t.OrderDate, '$.year'). Seems a bit too hackish.

Re:JSON Support in SQL Server 2016 by bjg on Tuesday May 19, 2015 @12:31AM (#9568147)
The article points out that you can use their ISJSON function as a check constraint on your column, guarding it from malformed data:

> ISJSON( jsonText ) that checks is the NVARCHAR text input properly formatted according to the JSON specification. You can use this function the create check constraints on NVARCHAR columns that contain JSON text.

Re:JSON Support in SQL Server 2016 by biot on Tuesday May 19, 2015 @10:32AM (#9570296)
Thanks... I somehow missed the check constraint ability, which addresses the malformed data issue.
Re:JSON Support in SQL Server 2016 by __Joker on Tuesday May 19, 2015 @12:44AM (#9568174)
Not to nitpick. But you want this validation to be default. In this case which it can't be.

Question is what stopped MS to just wrap this NVARCHAR with json validation and json access and give it as json type. May be native json type will be added in future versions. I think just they wanted to ball to rolling.

Re:JSON Support in SQL Server 2016 by taspeotis on Tuesday May 19, 2015 @01:08AM (#9568229)
> Question is what stopped MS to just wrap this NVARCHAR with json validation and json access and give it as json type

A large part of the blog post [1] is dedicated to this issue?

> In SQL Server 2016, JSON will be represented as NVARCHAR type. There are three reasons for this:

[1] http://blogs.msdn.com/b/jocapc/archive/2015/05/16/json-suppo...