PHP Convert Array ke JSON Object
$myArr = array("apple", "banana", "mango", "jackfruit");
$toJSON = json_encode($myArr);
echo $toJSON;
Lazy Loris
$myArr = array("apple", "banana", "mango", "jackfruit");
$toJSON = json_encode($myArr);
echo $toJSON;
function json2array(json){
var result = [];
var keys = Object.keys(json);
keys.forEach(function(key){
result.push(json[key]);
});
return result;
}
var obj = {name: "Martin", age: 30, country: "United States"};
// Converting JS object to JSON string
var json = JSON.stringify(obj);
console.log(json);
// Prints: {"name":"Martin","age":30,"country":"United States"}
"https://www.tutorialrepublic.com/faq/how-to-convert-js-object-to-json-string.php"
var jsonPerson = '{"first_name":"billy", "age":23}';
var personObject = JSON.parse(jsonPerson); //parse json string into JS object
var as = JSON.parse(jstring);
var array = ['a', 1, 'b', 2, 'c', 3],
object = {},
i
for (var i = 0; i < array.length; i += 2) {
object[array[i]] = array[i + 1];
}
console.log(object);