JSON and its relationship to Java Script

//What is JSON and how does it relate to Java Script?

//This is Object literal context that we have seen in the past. Here we can create and object and define it on the fly,.

    var objectliteral ={
        firstname:'Mary',
        isAProgrammer: true 
    }
    
    console.log(objectliteral);
        
        //Now Java Script can convert this object literal context to JSON using "stringify".
        
        console.log(JSON.stringify(objectliteral));

// Now JSON which is JavaScript Object Notation(JSON) uses the Java Script Object literal notation. So JSON is a subset of Java Script but JASON is not JavaScript because it has sticker rules. You can also convert the JSON script back to Java Script by this technique//

        var jsonValue = JSON.parse('{"firstname": "Mary","isAProgrammer": true}');   //Change back to Object
        
        console.log(jsonValue); 
        
        //Faking Name spaces
        
        //Name space: Container for variables and functions.  In Java script we can fake this 
        
        var greet = "Hello!";
        var greet = "Hola!";
        
        console.log(greet);  //greet variable replaced by "Hola"  So we can create a container to hold different version of the greet variable.
        
        var english ={};  //can create containers for English version
        
        var spanish = {};  //can create container for Spanish version
    
        english.greet = "Hello!";
        
        spanish.greet = "Hola!";
        
        console.log(english.greet);   //print "Hello"
        
        console.log(spanish.greet);   //print "Hola"
        
        english.greeting = {};
        
        spanish.greeting = {};
        
        english.greeting= "Only in America";
        
        spanish.greeting = "Only in Spain";
        
        console.log(english.greeting);  // prints "Only in America"
        
        console.log(spanish.greeting);  //print "Only in Spain"