Telerik Software Academy Databases.

Slides:



Advertisements
Similar presentations
Windows Basic and Dynamic Disk Borislav Varadinov Telerik Software Academy academy.telerik.com System Administrator Marian Marinov CEO of 1H Ltd.
Advertisements

HTML Forms, GET, POST Methods Tran Anh Tuan Edit from Telerik Academy
Make swiftly iOS development Telerik Academy Telerik Academy Plus.
Amazon S 3, App Engine Blobstore, Google Cloud Storage, Azure Blobs Svetlin Nakov Telerik Software Academy academy.telerik.com.
RPN and Shunting-yard algorithm Ivaylo Kenov Telerik Software Academy academy.telerik.com Technical Assistant
Shortest paths in edge-weighted digraph Krasin Georgiev Technical University of Sofia g.krasin at gmail com Assistant Professor.
Telerik Software Academy Telerik School Academy.
Asynchronous Programming with C# and WinRT
Unleash the Power of JavaScript Tooling Telerik Software Academy End-to-end JavaScript Applications.
Touch and Gestures with Xamarin Forms
Telerik School Academy ASP.NET MVC.
Character sequences, C-strings and the C++ String class, Working with Strings Learning & Development Team Telerik Software Academy.
Hybrid or Native?! Doncho Minkov Telerik Software Academy Senior Technical Trainer
Done already for your convenience! Telerik School Academy Unity 2D Game Development.
Processing Sequences of Elements Telerik School Academy C# Fundamentals – Part 1.
With Mocha and Karma Telerik Academy Telerik Software Academy.
C# Fundamentals – Part I
Welcome to the JSON-stores world Telerik Software Academy Databases.
NoSQL Concepts, Redis, MongoDB, CouchDB
The Business Plan and the Business Model Margarita Antonova Volunteer Telerik Academy academy.telerik.com Business System Analyst Telerik Corporation.
What are ADTs, STL Intro, vector, list, queue, stack Learning & Development Team Telerik Software Academy.
Making JavaScript code by template! Learning & Development Team Telerik Software Academy.
Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training Who, What, Why?
Access to known folders, using pickers, writing to and reading from files, caching files for future access George Georgiev Telerik Software Academy academy.telerik.com.
Accessing SQL Server and MySQL – Live Demo Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
Processing Matrices and Multidimensional Tables Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Learning & Development Telerik Software Academy.
Reading and Writing Text Files Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Telerik Software Academy ASP.NET Web Forms.
Classical OOP in JavaScript Classes and stuff Telerik Software Academy
Optimization problems, Greedy Algorithms, Optimal Substructure and Greedy choice Learning & Development Team Telerik Software.
Using Selenium for Mobile Web Testing Powered by KendoUI Telerik QA Academy Atanas Georgiev Senior QA Engineer KendoUI Team.
NoSQL Concepts, Redis, MongoDB, CouchDB Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
New features: classes, generators, iterators, etc. Telerik Academy Plus JavaScript.Next.
Throwing and Catching Exceptions Tran Anh Tuan Edit from Telerik Software Academy
Loops, Conditional Statements, Functions Tran Anh Tuan Edit from Telerik Academy
Private/Public fields, Module, Revealing Module Learning & Development Team Telerik Software Academy.
Building Data-Driven ASP.NET Web Forms Apps Telerik Software Academy ASP.NET Web Forms.
Course Introduction Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
Nikolay Kostov Telerik Software Academy Senior Software Developer and Trainer
Telerik Software Academy End-to-end JavaScript Applications.
What is a Database, MySQL Specifics Trần Anh Tuấn Edit from Telerik Software Academy
Planning and Tracking Software Quality Yordan Dimitrov Telerik Corporation Team Leader, Team Pulse, Team Leader, Team Pulse, Telerik Corporation,
What you need to know Ivaylo Kenov Telerik Corporation Telerik Academy Student.
Data binding concepts, Bindings in WinJS George Georgiev Telerik Software Academy academy.telerik.com Technical Trainer itgeorge.net.
Pavel Kolev Telerik Software Academy Senior.Net Developer and Trainer
Objects, Properties, Primitive and Reference Types Learning & Development Team Telerik Software Academy.
When and How to Refactor? Refactoring Patterns Alexander Vakrilov Telerik Corporation Senior Developer and Team Leader.
Free Training and Job for Software Engineers Svetlin Nakov, PhD Manager Technical Training Telerik Corp. Telerik Software Academy.
Free Training and Job for Software Engineers Svetlin Nakov, PhD Manager Technical Training Telerik Corp. Telerik Software Academy.
Access to known folders, using pickers, writing to and reading from files, caching files for future access George Georgiev Telerik Software Academy academy.telerik.com.
Doing the Canvas the "easy way"! Learning & Development Telerik Software Academy.
Creating and Running Your First C# Program Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
Course Overview Doncho Minkov Telerik Software Academy Technical Trainer
Data Types, Primitive Types in C++, Variables – Declaration, Initialization, Scope Telerik Software Academy academy.telerik.com Learning and Development.
The past, the present, the future Learning & Development Team Telerik Software Academy.
Connecting, Queries, Best Practices Tran Anh Tuan Edit from Telerik Software Academy
Processing Sequences of Elements Telerik Software Academy C# Fundamentals – Part 2.
Telerik JavaScript Framework Telerik Software Academy Hybrid Mobile Applications.
Processing JSON in.NET JSON, JSON.NET LINQ-to-JSON and JSON to XML SoftUni Team Technical Trainers Software University
Things start to get serious Telerik Software Academy JavaScript OOP.
Learning & Development Mobile apps for iPhone & iPad.
Processing Matrices and Multidimensional Tables Telerik Software Academy C# Fundamentals – Part 2.
Nikolay Kostov Telerik Software Academy academy.telerik.com Team Lead, Senior Developer and Trainer
Functions and Function Expressions Closures, Function Scope, Nested Functions Telerik Software Academy
Implementing Control Logic in C# Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical trainer
Mocking tools for easier unit testing Telerik Software Academy High Quality Code.
What why and how? Telerik School Academy Unity 2D Game Development.
Windows Security Model Borislav Varadinov Telerik Software Academy academy.telerik.com System Administrator
Parsing JSON JSON.NET, LINQ-to-JSON
Presentation transcript:

Telerik Software Academy Databases

 The JSON data format  Rules and features  Usage  JSON.NET Overview  Installation and usage  LINQ-to-JSON  JSON to XML and XML to JSON

What is JSON?

 JSON (JavaScript Object Notation) is a lightweight data format  Human and machine-readable  Based on the way of creating objects in JS  Platform independent – can be used with any programming language

 The JSON data format follows the rules of object creation in JavaScript  Strings, numbers and Booleans are valid JSON "this is string and is valid JSON"  Arrays are valid JSON [5, 'string', true]  Objects are valid JSON { "firstname": "Doncho", "firstname": "Doncho", "lastname": "Minkov", "lastname": "Minkov", "occupation": "Technical trainer" "occupation": "Technical trainer"}

 The JSON data format follows the rules of object creation in JavaScript  Strings, numbers and Booleans are valid JSON "this is string and is valid JSON"  Arrays are valid JSON [5, 'string', true]  Objects are valid JSON { "firstname": "Doncho", "firstname": "Doncho", "lastname": "Minkov", "lastname": "Minkov", "occupation": "Technical trainer" "occupation": "Technical trainer"} The double quotes for the keys are mandatory

How to parse JSON in.NET?

.NET has built-in JSON serializer:  The JavaScriptSerializer class, contained in System.Web.Extensions assembly  JavaScriptSerializer is able to parse C# object to JSON string and vice versa: var place = new Place(…); var serializer = new JavaScriptSerializer(); var jsonPlace = serializer.Serialize(place); var objPlace = serializer.Deserialize (jsonPlace);

Live Demo

 JavaScript serializer has nice features:  Serializing objects to JSON and vice versa  Correct parsing of dictionaries: digits = new Dictionary digits = new Dictionary { { "one", 1}, { "one", 1}, { "two", 2}, { "two", 2}, … }; };

 JavaScript serializer has nice features:  Serializing objects to JSON and vice versa  Correct parsing of dictionaries: digits = new Dictionary digits = new Dictionary { { "one", 1}, { "one", 1}, { "two", 2}, { "two", 2}, … }; };{ "one": 1, "two": 2, "one": 1, "two": 2, "three": 3, "three": 3, "four": 4, "four": 4,…} Is parsed to

 JavaScript serializer has nice features:  Serializing objects to JSON and vice versa  Correct parsing of dictionaries: digits = new Dictionary digits = new Dictionary { { "one", 1}, { "one", 1}, { "two", 2}, { "two", 2}, … }; };{ "one": 1, "two": 2, "one": 1, "two": 2, "three": 3, "three": 3, "four": 4, "four": 4,…} Is parsed to

Live Demo

Better JSON parsing than with JavaScriptSerializer

 JavaScriptSerializer is good  But JSON.NET is better  JSON.NET:  Has better performance  Supports LINQ-to-JSON  Has an out-of-the-box support for parsing between JSON and XML

 To install JSON.NET, run in the Package Manager Console: $ Install-Package Newtonsoft.Json  Has two primary methods:  Serialize an object: var serializedPlace = JsonConvert.SerializeObject(place); JsonConvert.SerializeObject(place); var deserializedPlace = JsonConvert.DeserializeObject (serializedPlace); JsonConvert.DeserializeObject (serializedPlace);  Deserialize an object:

Live Demo

 JSON.NET can be configured to:  Indent the output JSON string  To convert JSON to anonymous types  To control the casing and properties to parse  To skip errors  JSON.NET also supports:  LINQ-to-JSON  Direct parse between XML and JSON

var json 'firstName': 'Doncho'," 'lastName': 'Minkov', 'occupation': 'Technical Trainer' }"; 'lastName': 'Minkov', 'occupation': 'Technical Trainer' }"; var template = new { FirstName = "", FirstName = "", Lastname = "", Lastname = "", Occupation = "" Occupation = ""}; var person = JsonConvert.DeserializeAnonymousType(json, template); JsonConvert.DeserializeAnonymousType(json, template);  To indent the output string use Formattingg.Indented : JsonConvert.SerializeObject(place, Formatting.Indented);  Deserializing to anonymous types:

var json 'firstName': 'Doncho'," 'lastName': 'Minkov', 'occupation': 'Technical Trainer' }"; 'lastName': 'Minkov', 'occupation': 'Technical Trainer' }"; var template = new { FirstName = "", FirstName = "", Lastname = "", Lastname = "", Occupation = "" Occupation = ""}; var person = JsonConvert.DeserializeAnonymousType(json, template); JsonConvert.DeserializeAnonymousType(json, template); Should provide a template  To indent the output string use Formattingg.Indented : JsonConvert.SerializeObject(place, Formatting.Indented);  Deserializing to anonymous types:

Live Demo

 By default JSON.NET takes each Property/Field from the public interface of a class and parses it  This can be controlled using attributes: public class User { [JsonProperty("user")] [JsonProperty("user")] public string Username{get;set;} public string Username{get;set;} [JsonIgnore] [JsonIgnore] public string Password{get;set;} public string Password{get;set;}}

 By default JSON.NET takes each Property/Field from the public interface of a class and parses it  This can be controlled using attributes: public class User { [JsonProperty("user")] [JsonProperty("user")] public string Username{get;set;} public string Username{get;set;} [JsonIgnore] [JsonIgnore] public string Password{get;set;} public string Password{get;set;}} Tells the converter to parse "Username" to "user"

 By default JSON.NET takes each Property/Field from the public interface of a class and parses it as is  This can be controlled using attributes: public class User { [JsonProperty("user")] [JsonProperty("user")] public string Username{get;set;} public string Username{get;set;} [JsonIgnore] [JsonIgnore] public string Password{get;set;} public string Password{get;set;}} Tells the converter to skip the property "Password" Tells the converter to parse "Username" to "user"

Live Demo

 JSON.NET has a support for LINQ-to-JSON var jsonObj = JObject.Parse(json); Console.WriteLine("Places in {0}:", jsonObj["name"]); jsonObj["places"].Select( pl => pl => string.Format("{0}) {1} ({2})", string.Format("{0}) {1} ({2})", index++, index++, pl["name"], pl["name"], string.Join(", ", string.Join(", ", pl["categories"].Select( pl["categories"].Select( cat => cat["name"])))) cat => cat["name"])))).Print();.Print();

Live Demo

 Conversions from JSON to XML are done using two methods:  XML to JSON string jsonFromXml = JsonConvert.SerializeXNode(doc); XDocument xmlFromJson = JsonConvert.DeserializeXNode(json);  JSON to XML

Live Demo

форум програмиране, форум уеб дизайн курсове и уроци по програмиране, уеб дизайн – безплатно програмиране за деца – безплатни курсове и уроци безплатен SEO курс - оптимизация за търсачки уроци по уеб дизайн, HTML, CSS, JavaScript, Photoshop уроци по програмиране и уеб дизайн за ученици ASP.NET MVC курс – HTML, SQL, C#,.NET, ASP.NET MVC безплатен курс "Разработка на софтуер в cloud среда" BG Coder - онлайн състезателна система - online judge курсове и уроци по програмиране, книги – безплатно от Наков безплатен курс "Качествен програмен код" алго академия – състезателно програмиране, състезания ASP.NET курс - уеб програмиране, бази данни, C#,.NET, ASP.NET курсове и уроци по програмиране – Телерик академия курс мобилни приложения с iPhone, Android, WP7, PhoneGap free C# book, безплатна книга C#, книга Java, книга C# Николай Костов - блог за програмиране