JSON AND MVC

JSON stands for JavaScript Object Notation and is a syntax for storing and exchanging data in a human- readable format. JSON is most commonly used to transfer data between a server and a web application. Additionally, web services and APIs use JSON format to provide public data. JSON is language independent and is easy to be written and read.  Below I have provided JSON datatypes and the corresponding syntax.

  • Number – integer or floating point.
var obj = {age: 21}
  • String – double quoted Unicode character.
var obj = {name: “Elena”}
  • Boolean – true or false.
var obj = {“passing : true”}
  • Array – collection of values.
{
“countries”:[
               {“language”: “Turkish”, “capital”: “Ankara”},

               {“language”: “Italian”, “capital”: “Rome”},

               {“language”: “German”, “capital”: “Berlin”}
]
}
  • Value – can be a string, number, null, true or false.
var num = 10;
var name = “Elena”
var i = null;
  • Object – ordered set of value pairs
{
       “language”: “Turkish”,
       “capital” : “Ankara”
}

       empty object

var emptyObj = {};

       new object

var newObj = new Object ();
  • Whitespace – usually is added to make the code more readable
var object = {“name”: ”Elena Cina”}
  • Null – indicates an empty type

Be aware that JSON and JavaScript are not the same concept. JavaScript is a programming language while as I have explained above JSON is a language independent data exchange format.

—————————————————————————————————————————————–

MVC is an architectural style and stands for Model View Controllers.

mvc

According to this style subsystems are classifies into three different types.

  1. Model subsystems maintains domain knowledge. They are totally independent form the other two types of subsystems. However, any change in model subsystems is propagated to the view subsystem.
  2. View subsystems display the data to the users.
  3. Controller subsystems control interactions with the users. They act on Model and View subsystems.

Leave a Reply

Your email address will not be published. Required fields are marked *