JavaScript JSON Encoder and Decoder Example

JavaScript JSON Encoder and Decoder Example

Today, We want to share with you JavaScript JSON Encoder and Decoder Example.
In this post we will show you JSON Encoder and Decoder For JavaScript with Example, hear for jquery Decode and Encode JSON we will give you demo and example for implement.
In this post, we will learn about JSON Encoder/Decoder Functions with an example.

What is JSON?

Answer : JSON(json stands for JavaScript Object Notation) is a most lightweight and very faster then XML computer data interchange(object,array,etc..) format.

The Following List Of Characteristics of JSON

1st : JSON is very easy to read mode and write mode.
2nd : It is a most lightweight with very faster more than XML text-based interchange format Data.
3rd : JSON is all language (Global)independent Data.

Json encoder and decoder tool used to convert or computes json encoded format data and decoded format data strings for the given text:

Following the List of Tools for JSON Encoder and Decoder :

1st :

2nd :

3rd :

JSON.stringify : Example

1st : JSON.stringify({}); // Result is : ‘{}’
2nd : JSON.stringify(true); // Result is : ‘true’
3rd : JSON.stringify(‘pakainfo’); // Result is : ‘”pakainfo”‘
4th : JSON.stringify([2, ‘false’, false]); // Result is : ‘[2,”false”,false]’
5th : JSON.stringify({ j: 50 }); //Result is : ‘{“j”:50}’
3th : JSON.stringify({ abc: 5, def: 6 }); //Result is: ‘{“abc”:5,”def”:6}’ or ‘{“def”:6,”abc”:5}’

Convert – an object to a string in javascript, used to JSON.stringify function in javascript:

var simple_json_text_demo = JSON.stringify(name_your_object_data, null, 2);

Convert – JSON string to object in javascript, used to JSON.parse function in javascript:

var name_your_object_data = JSON.parse(simple_json_text_demo);

jQuery with json – encode and decode

var simpleappmyObj = {script: "example", "demo": "simpleblogspotpakainfo"};

// Result is = : {"script":"example","demo":"simpleblogspotpakainfo"}

Converting a JSON Text data to a JavaScript Object with Example

JSON Encoder and Decoder For JavaScript with Example

<h2>Create Simple Object from data of JSON String For JavaScript with Example</h2>

<p id="simpledemo"></p>

var text_all = '{"userlistex":[' +
'{"userfirstName":"pakainfo","userlastName":"king" },' +
'{"userfirstName":"","userlastName":"wordpress" },' +
'{"userfirstName":"ngking","userlastName":"patel" }]}';

obj = JSON.parse(text_all);
document.getElementById("simpledemo").innerHTML =
obj.userlistex[1].userfirstName + " " + obj.userlistex[1].userlastName;

JSON Format supports – DataTypes List

1 : Number
2 : String
3 : Boolean
4 : Array
5 : Value
6 : Object
7 : Whitespace
8 : null

Also Read This ๐Ÿ‘‰   how to check username and password from database in using c#

More Describes :