str to json code example
Example 1: python json string to object
import json
x = '{ "name":"John", "age":30, "city":"New York"}'
y = json.loads(x)
print(y["age"])
Example 2: Javascript object to JSON string
var person={"first_name":"Tony","last_name":"Hawk","age":31};
var personJSONString=JSON.stringify(person);
Example 3: string to json c#
JObject json = JObject.Parse(str);
Example 4: javascript parse json
const json = '{ "fruit": "pineapple", "fingers": 10 }';
const obj = JSON.parse(json);
console.log(obj.fruit, obj.fingers);
Example 5: object json parse javascript
var objJson1 = JSON.parse(JSON.stringify(objNotJson1));
Example 6: python to json
x = {
"name": "John",
"age": 30,
"city": "New York"
}
y = json.dumps(x)