Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

convert json string into json object


const jsonString = '{ "key": "value", "key2": ["a","b"] }';
const obj = JSON.parse( jsonString );

alert( obj.key );     // "value"
alert( obj.key2[1] ); // "b"
Comment

Converting string to json object

var oTemp = JSON.parse(buf.toString());
Comment

string to .json

Copy 
1const jsonStr = '{"name":"Infinitbility","gender":"male"}';
2const jsonObj = JSON.parse(jsonStr);
3console.log(jsonObj); // {name: 'Infinitbility', gender: 'male'}
4console.log(jsonObj.name); // Infinitbility
Comment

Convert object to Json String

List<userdetails> details = new List<userdetails>();
userdetails user = new userdetails();
details.Add(new userdetails { userid = 1, username = "suresh", location = "chennai" });
string strserialize = JsonConvert.SerializeObject(details);
Comment

PREVIOUS NEXT
Code Example
Javascript :: checkbox default value and checked value get in jquery 
Javascript :: polling in js 
Javascript :: how to add checked in javascript 
Javascript :: javascript check if string contains special characters 
Javascript :: js char array to string 
Javascript :: how to put react compnent to bottom 
Javascript :: user input in js 
Javascript :: reducer in react example 
Javascript :: create url with query parameters javascript 
Javascript :: vuejs get value of checkbox group 
Javascript :: jquery option not disabled 
Javascript :: get element by xpath 
Javascript :: js array from 
Javascript :: generate a random number between min and max 
Javascript :: Difference in push and navigate in react Navigation 
Javascript :: script tag inside react component 
Javascript :: how to read a file in javascript 
Javascript :: types of loops in javascript 
Javascript :: run a local instance of Kibana on docker and connect to elasticsearch 
Javascript :: javascript get time 
Javascript :: slice method in js 
Javascript :: mongoose findone exclude perticular field 
Javascript :: recursive function for fibonacci series in java javascript 
Javascript :: sequelize migration skeleton 
Javascript :: generate random color array javascript 
Javascript :: discord.js setactivity 
Javascript :: what is polyfills in angular 
Javascript :: jquery number counter 
Javascript :: get url parameters javascript 
Javascript :: vue mounted refresh page once 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =