{. “speaker”:. “Emanuele Zanchettin”,. “session” : { “speaker”: “Emanuele Zanchettin”, “session” : “JSON before and after SQL SERVER 2016” }
Sponsors!
Agenda
Agenda JSON overview Using JSON before SQL Server 2016 Using JSON with/after SQL Server 2016 A real scenario (simplified) Conclusions would you like to play a game?
Have you never used JSON before? Too much early this morning .. a very busy day .. and now .. ?? Are you awake? Try to raise your hand, just one Try to smile Who is using … (raise at least one hand) SQL Server? SS Management Studio? Who is … (raise at least one hand) A developer? A DBAdministrator? Other? Have you never used JSON before?
me - Emanuele Zanchettin 15+ years experience about IT Data architect and consultant about SQLServer and Azure SQL Database Lead of Software Development @ Sci-Tech Labs Daresbury (UK) Co-founder thinkIT (IT) Community Lead Official Microsoft Community Speaker at national and international conferences and user groups about SQLServer e Azure SQL Database ezanchettin@thinkit.it – http://www.thinkit.it/
JSON overview
JSON overview - History In computing, JSON, acronym of JavaScript Object Notation, is an open-standard file format to transmit data using asynchronous browser/server communication https://en.wikipedia.org/wiki/JSON Based on STD JS December 1999 Indipendent Alternative of XML
JSON overview – data types Data types supported by this format are: boolean number string array and associative array null object Not supported data types are: binary .. Base64
JSON overview – XML vs JSON XML <employees> <employee> <name>Tim</name> <gender>M</gender> </employee> <name>Tom</name> </employees > JSON { "employees": [ "name": "Tim", "gender": "M" }, "name": "Tom", } ]
JSON overview – JSON roles An object must be included between { and } (braces) Couple keys/values are separated by : (colon) Collections of couple keys/values are separated by , (comma) Arrays are represented by [ ] (square brakets) and values are separated by , (comma)
JSON overview – data type conversion JSON «value» types Number, decimal signed with eventual fraction and exponent E String, delimited by " and managed with \ as escape char Boolean, true or false Null Array, delimited by [] as an empty list or with elements separated by , Object, delimited by { } with eventual couple key/value separated by , Easy, isn’t!?
JSON overview – strings Be careful in case of managing of UNICODE strings, except " and \ and control char, for example \" double quote \\ reverse bar \/ bar \b behind \f end page \r return \n new row \t tab \u<hex 4 digit> any char with hex representation
JSON before of SQL Server 2016
JSON before of SQL Server 2016 Not native support Are there alternatives? Don’t use JSON at DB level Maintain the JSON as not structured data into the DB Migrate to SQL Server 2016 !?!? Parsing the JSON at DB level .. Accepting all limits .. Enjoy, it’s possible to manage in «easy» mode the JSON using previous versions of SQL Server 2016 …
DEMO JSON2014
JSON with/after SQL Server 2016
JSON with/after SQL Server 2016 Native support OUPUT FOR JSON PATH FOR JSON AUTO INPUT OPENJSON ISJSON JSON_VALUE JSON_QUERY
DEMO JSON2016
A real scenario (simplified) – do you like wine? Versions: { // PackageV1 "DeviceIdentifier": null, "Temperatures": null } { // PackageV2 "Temperatures": null, "Version": null { // PackageV3 "Version": null, "Temperature": 0.0, "Humidity": 0.0
DEMO WINE
Conclusions – only vantages No setup and/or installation needed Few and easy command to remember Easy to use, to integrate and to maintain Two ways transformation JSON <-> relational model Hibrid model with data storing Total flexibility on JSON structure on data storing Indexes to have better performances
Q&A Questions? ezanchettin@thinkit.it @_thinkIT_ Here, there, around the world
Please, don’t forget to complete Thanks Thank you very much for listening Please, don’t forget to complete the feedback form
Agenda JSON overview Using JSON with/after SQL Server 2016 Using JSON before SQL Server 2016 A real scenario (simplified) Conclusions no thanks would you like to play a game?
Have you never used JSON before? Too much early this morning .. a very busy day .. and now .. ?? Are you awake? Try to raise your hand, just one Try to smile Who is using … (raise at least one hand) SQL Server? SS Management Studio? Who is … (raise at least one hand) A developer? A DBAdministrator? Other? Have you never used JSON before?
me - Emanuele Zanchettin 15+ years experience about IT Data architect and consultant about SQLServer and Azure SQL Database Lead of Software Development @ Sci-Tech Labs Daresbury (UK) Co-founder thinkIT (IT) Community Lead Official Microsoft Community Speaker at national and international conferences and user groups about SQLServer e Azure SQL Database ezanchettin@thinkit.it – http://www.thinkit.it/
Conclusions – only vantages No setup and/or installation needed Few and easy command to remember Easy to use, to integrate and to maintain Two ways transformation JSON <-> relational model Hibrid model with data storing Total flexibility on JSON structure on data storing Indexes to have better performances
A real scenario – do you like wine? Versions: { // PackageV1 "DeviceIdentifier": null, "Temperatures": null } { // PackageV2 "Temperatures": null, "Version": null { // PackageV3 "Version": null, "Temperature": 0.0, "Humidity": 0.0
DEMO WINE
JSON with/after SQL Server 2016
JSON with/after SQL Server 2016 Native support OUPUT FOR JSON PATH FOR JSON AUTO INPUT OPENJSON ISJSON JSON_VALUE JSON_QUERY
DEMO JSON2016
JSON before of SQL Server 2016
JSON before of SQL Server 2016 Not native support Are there alternatives? Don’t use JSON at DB level Maintain the JSON as not structured data into the DB Migrate to SQL Server 2016 !?!? Parsing the JSON at DB level .. Accepting all limits .. Enjoy, it’s possible to manage in «easy» mode the JSON using previous versions of SQL Server 2016 …
DEMO JSON2014
JSON overview
JSON overview - History In computing, JSON, acronym of JavaScript Object Notation, is an open-standard file format to transmit data using asynchronous browser/server communication https://en.wikipedia.org/wiki/JSON Based on STD JS December 1999 Indipendent Alternative of XML
JSON overview – data types Data types supported by this format are: boolean number string array and associative array null object Not supported data types are: binary .. Base64
JSON overview – XML vs JSON XML <employees> <employee> <name>Tim</name> <gender>M</gender> </employee> <name>Tom</name> </employees > JSON { "employees": [ "name": "Tim", "gender": "M" }, "name": "Tom", } ]
JSON overview – JSON roles An object must be included between { and } (braces) Couple keys/values are separated by : (colon) Collections of couple keys/values are separated by , (comma) Arrays are represented by [ ] (square brakets) and values are separated by , (comma)
JSON overview – data type conversion JSON «value» types Number, decimal signed with eventual fraction and exponent E String, delimited by " and managed with \ as escape char Boolean, true or false Null Array, delimited by [] as an empty list or with elements separated by , Object, delimited by { } with eventual couple key/value separated by , Easy, isn’t!?
JSON overview – strings Be careful in case of managing of UNICODE strings, except " and \ and control char, for example \" double quote \\ reverse bar \/ bar \b behind \f end page \r return \n new row \t tab \u<hex 4 digit> any char with hex representation
Q&A Questions? ezanchettin@thinkit.it @_thinkIT_ Here, there, around the world
Please, don’t forget to complete Thanks Thank you very much for listening and playing the game Please, don’t forget to complete the feedback form