{"id":319058,"date":"2016-11-15T19:53:08","date_gmt":"2016-11-16T03:53:08","guid":{"rendered":"https:\/\/cm-edgetun.pages.dev\/en-us\/research\/?post_type=msr-project&#038;p=319058"},"modified":"2017-07-20T00:48:12","modified_gmt":"2017-07-20T07:48:12","slug":"json-server-2","status":"publish","type":"msr-project","link":"https:\/\/cm-edgetun.pages.dev\/en-us\/research\/project\/json-server-2\/","title":{"rendered":"JSON Server"},"content":{"rendered":"<p>JSON Server is a library that connects to a SQL database instance, stores JSON documents in tables and queries JSON documents through a JSON query language. It currently supports SQL Server\u00a0(version 2012 and onward)\u00a0and MariaDB (10.0 and onward)\u00a0as the underlying database, and three query languages: MongoDB query language, Azure DocumentDB query language and JSON Server&#8217;s own query language. JSON Server is not an independent database, but a middleware that accepts operations against JSON documents and translates them to SQL queries executed in the underlying system. As such, JSON Server provides a view of a JSON database, while completely operating on SQL Server or MariaDB.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-322700 alignnone\" src=\"https:\/\/cm-edgetun.pages.dev\/en-us\/research\/wp-content\/uploads\/2016\/11\/json_server.png\" alt=\"json_server\" width=\"427\" height=\"350\" srcset=\"https:\/\/cm-edgetun.pages.dev\/en-us\/research\/wp-content\/uploads\/2016\/11\/json_server.png 867w, https:\/\/cm-edgetun.pages.dev\/en-us\/research\/wp-content\/uploads\/2016\/11\/json_server-300x246.png 300w, https:\/\/cm-edgetun.pages.dev\/en-us\/research\/wp-content\/uploads\/2016\/11\/json_server-768x629.png 768w\" sizes=\"auto, (max-width: 427px) 100vw, 427px\" \/><\/p>\n<h1>Features<\/h1>\n<p>JSON Server\u00a0provides features a standard JSON database is expected to have. In addition, since JSON Server relies on SQL DBs, it inherits many features that are common in the relational world that are often missing\u00a0in native JSON databases.<\/p>\n<ul>\n<li><strong>Databases and collections<\/strong>. A database in JSON Server is a conventional SQL database instance, within which one or more document collections are created through JSON Server\u2019s API\u2019s. Unlike most JSON databases in which operations must be bound to a single collection, JSON Server supports cross-collection operations.<\/li>\n<li><strong>Data manipulations<\/strong>. JSON Server provides API\u2019s to insert JSON documents to a collection. Document deletion is done by a DELETE statement specifying documents matching criteria. JSON Server does not support modifying an existing document at the moment, a feature that will be supported in a future release. Currently, document modifications can be done by first deleting the document from the collection, modifying it in the application, and then inserting the new document back to the collection. JSON Server provides transaction guarantees. The three steps can be wrapped in one transaction, resulting in no intermediate states in case some steps fail.<\/li>\n<li><strong>Queries<\/strong>. JSON Server provides a query language to query JSON documents. The language is akin to XQuery, providing much more expressive power than the languages of other alternatives. JSON Server also supports two other popular languages, MongoDB and Azure DocumentDB.<\/li>\n<li><strong>Transactions<\/strong>. All operations in JSON Server are transaction-safe. What is more, a transaction\u2019s scope can span more than one document, in the same collection or separate collections.<\/li>\n<li>SQL-related features. JSON Server inherits many features from the SQL database it connects to. Below is a short list of features that are crucial to administration tasks:\n<ul>\n<li><strong>Security<\/strong>. JSON Server uses the authentication mechanism of the SQL DB it connects to for access control. A user can access a database if SQL DB says so. JSON Server also enjoys other security features of SQL DBs, e.g.,\u00a0encryption.<\/li>\n<li><strong>Replication<\/strong>.\u00a0JSON Server stores JSON documents in SQL databases. A replication of the database will result in a replication of all JSON data. As such, it is convenient to deliver a JSON solution for various in-production environment.<\/li>\n<li><strong>Backup<\/strong>. JSON Server maintains SQL databases that are visible to SQL DB administrators. Administrators can apply backup operations to the database explicitly\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h1>Dependency<\/h1>\n<p>JSON Server needs the following libraries: (1) <a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" target=\"_blank\" href=\"http:\/\/json.codeplex.com\/\">Json.NET<span class=\"sr-only\"> (opens in new tab)<\/span><\/a>,\u00a0(2)\u00a0 <a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" target=\"_blank\" href=\"http:\/\/dev.mysql.com\/downloads\/connector\/net\/\">ADO.NET driver for MySQL<span class=\"sr-only\"> (opens in new tab)<\/span><\/a>, when you connect to\u00a0MariaDB.<\/p>\n<h1>Getting Started<\/h1>\n<p>JSON Server is a DLL library. You reference the library in your application and open a database\u00a0using\u00a0a SQL DB connection string.<\/p>\n<div>\n\n\t\t\t<section id=\"sample-code-1\" class=\"c-tabs_tabpanel padding-top-sp3\" data-bi-aN=\"sample code 1\">\n\t\t\t<h2 class=\"visually-hidden\">sample code 1<\/h2>\n\n\t\t\t<div class=\"ms-row\">\n\t\t\t\t<div class=\"l-col-24-24\">\n\t\t\t\t\t<\/p>\n<pre>string connectionString = @\"Data Source=(local);Initial Catalog=JsonTesting;Integrated Security=true;\";\r\nJsonServerConnection jdb = new JsonServerConnection(connectionString);\r\ntry {\r\n  \/\/ Connect to a JSON database\r\n  jdb.Open(true);\r\n\u00a0\u00a0jdb.Close();\r\n}\r\ncatch(DatabaseException e) {\r\n  \/\/ Exception handling goes here\r\n}<\/pre>\n<p>\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t<\/section>\n\t\n\t\n<\/div>\n<div>When the connection string points to a MariaDB instance, you open a JSON database in MariaDB:<\/div>\n<div>\n\n\t\t\t<section id=\"sample-code-2\" class=\"c-tabs_tabpanel padding-top-sp3\" data-bi-aN=\"sample code 2\">\n\t\t\t<h2 class=\"visually-hidden\">sample code 2<\/h2>\n\n\t\t\t<div class=\"ms-row\">\n\t\t\t\t<div class=\"l-col-24-24\">\n\t\t\t\t\t<\/p>\n<pre>string connectionString = @\"server=127.0.0.1;uid=root;pwd=xxx;database=jsontesting;\";\r\nJsonServerConnection jdb = new JsonServerConnection(connectionString, DatabaseType.Mariadb);\r\ntry {\r\n\u00a0 \/\/ Connect to a JSON database\r\n\u00a0 jdb.Open(true);\r\n\u00a0\u00a0jdb.Close();\r\n}\r\ncatch(DatabaseException e) {\r\n\u00a0 \/\/ Exception handling goes here\r\n}<\/pre>\n<p>\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t<\/section>\n\t\n\t\n<\/div>\n<div>Once you open a JSON database, you send queries through JsonServerConnection and retrieve results through IDataReader.<\/div>\n<div>\n\n\t\t\t<section id=\"sample-code-3\" class=\"c-tabs_tabpanel padding-top-sp3\" data-bi-aN=\"sample code 3\">\n\t\t\t<h2 class=\"visually-hidden\">sample code 3<\/h2>\n\n\t\t\t<div class=\"ms-row\">\n\t\t\t\t<div class=\"l-col-24-24\">\n\t\t\t\t\t<\/p>\n<pre>try {\r\n  jdb.Open();\r\n  if (!jdb.ContainsCollection(\"ExampleCollection\")) {\r\n    jdb.CreateCollection(\"ExampleCollection\");\r\n  }\r\n  string doc1 = @\"{\"\"name\"\":\"\"sue\"\", \"\"age\"\":19, \"\"badges\"\":[\"\"blue\"\", \"\"black\"\"]}\";\r\n  string doc2 = @\"{\"\"name\"\":\"\"bob\"\", \"\"age\"\":42, \"\"badges\"\":[\"green\"]}\";\r\n  jdb.InsertJson(doc1, \"ExampleCollection\");\r\n  jdb.InsertJson(doc2, \"ExampleCollection\");\r\n  \r\n  string queryString = @\"for d in ('ExampleCollection') WHERE d.age < 30 SELECT Doc(d)\";\r\n  using(IDataReader reader = jdb.ExecuteReader(queryString)) {\r\n    while (reader.Read()) {\r\n\u00a0\u00a0\u00a0   \/\/ Retrieve results through IDataReader\r\n\u00a0   }\r\n  }\r\n  jdb.Close();\r\n}\r\ncatch (Exception e) {\r\n  \/\/ Exception handling goes here  \r\n}<\/pre>\n<p>\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t<\/section>\n\t\n\t\n<p>Read the <a href=\"https:\/\/cm-edgetun.pages.dev\/en-us\/research\/publication\/json-server-user-manual\/\">user manual<\/a> for the full language specification and programming API&#8217;s.<\/p>\n<h1>Download<\/h1>\n<p>JSON Server is\u00a0currently available as a binary DLL <a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" target=\"_blank\" href=\"https:\/\/github.com\/Microsoft\/GraphView\/blob\/Maria\/references\/JsonServer.dll\">here<span class=\"sr-only\"> (opens in new tab)<\/span><\/a>.<\/p>\n<h1>Get Help<\/h1>\n<p><a href=\"https:\/\/cm-edgetun.pages.dev\/en-us\/research\/publication\/json-server-user-manual\/\">User manual<\/a> is the first place to get help. It introduces JSON Server&#8217;s own query language, programming API&#8217;s and many code samples.<\/p>\n<p>Ask questions, report bugs and discuss issues at this <a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" target=\"_blank\" href=\"https:\/\/groups.google.com\/d\/forum\/json-server\">Google group<span class=\"sr-only\"> (opens in new tab)<\/span><\/a>.<\/p>\n<p>To talk to us in private, write to jsonserver@microsoft.com<\/p>\n<h1>License<\/h1>\n<p>JSON Server is under the MIT license.<\/p>\n\n\t\t\t<section id=\"license\" class=\"c-tabs_tabpanel padding-top-sp3\" data-bi-aN=\"license\">\n\t\t\t<h2 class=\"visually-hidden\">license<\/h2>\n\n\t\t\t<div class=\"ms-row\">\n\t\t\t\t<div class=\"l-col-24-24\">\n\t\t\t\t\t<\/p>\n<pre>JSON Server \r\n\r\nCopyright (c) 2016 Microsoft Corporation \r\n\r\nAll rights reserved. \r\n\r\nMIT License \r\n\r\nPermission 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 furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.<\/pre>\n<pre>THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.<\/pre>\n<p>\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t<\/section>\n\t\n\t\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>JSON Server is a library that connects to a SQL database instance, stores JSON documents in tables and queries JSON documents through a JSON query language. It currently supports SQL Server\u00a0(version 2012 and onward)\u00a0and MariaDB (10.0 and onward)\u00a0as the underlying database, and three query languages: MongoDB query language, Azure DocumentDB query language and JSON Server&#8217;s [&hellip;]<\/p>\n","protected":false},"featured_media":0,"template":"","meta":{"msr-url-field":"","msr-podcast-episode":"","msrModifiedDate":"","msrModifiedDateEnabled":false,"ep_exclude_from_search":false,"_classifai_error":"","footnotes":""},"research-area":[13563],"msr-locale":[268875],"msr-impact-theme":[],"msr-pillar":[],"class_list":["post-319058","msr-project","type-msr-project","status-publish","hentry","msr-research-area-data-platform-analytics","msr-locale-en_us","msr-archive-status-active"],"msr_project_start":"2016-11-16","related-publications":[],"related-downloads":[],"related-videos":[],"related-groups":[],"related-events":[],"related-opportunities":[],"related-posts":[],"related-articles":[],"tab-content":[],"slides":[],"related-researchers":[],"msr_research_lab":[],"msr_impact_theme":[],"_links":{"self":[{"href":"https:\/\/cm-edgetun.pages.dev\/en-us\/research\/wp-json\/wp\/v2\/msr-project\/319058","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cm-edgetun.pages.dev\/en-us\/research\/wp-json\/wp\/v2\/msr-project"}],"about":[{"href":"https:\/\/cm-edgetun.pages.dev\/en-us\/research\/wp-json\/wp\/v2\/types\/msr-project"}],"version-history":[{"count":2,"href":"https:\/\/cm-edgetun.pages.dev\/en-us\/research\/wp-json\/wp\/v2\/msr-project\/319058\/revisions"}],"predecessor-version":[{"id":402836,"href":"https:\/\/cm-edgetun.pages.dev\/en-us\/research\/wp-json\/wp\/v2\/msr-project\/319058\/revisions\/402836"}],"wp:attachment":[{"href":"https:\/\/cm-edgetun.pages.dev\/en-us\/research\/wp-json\/wp\/v2\/media?parent=319058"}],"wp:term":[{"taxonomy":"msr-research-area","embeddable":true,"href":"https:\/\/cm-edgetun.pages.dev\/en-us\/research\/wp-json\/wp\/v2\/research-area?post=319058"},{"taxonomy":"msr-locale","embeddable":true,"href":"https:\/\/cm-edgetun.pages.dev\/en-us\/research\/wp-json\/wp\/v2\/msr-locale?post=319058"},{"taxonomy":"msr-impact-theme","embeddable":true,"href":"https:\/\/cm-edgetun.pages.dev\/en-us\/research\/wp-json\/wp\/v2\/msr-impact-theme?post=319058"},{"taxonomy":"msr-pillar","embeddable":true,"href":"https:\/\/cm-edgetun.pages.dev\/en-us\/research\/wp-json\/wp\/v2\/msr-pillar?post=319058"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}