Answers for "json decode"

19

php json_decode

$personJSON = '{"name":"Johny Carson","title":"CTO"}';

$person = json_decode($personJSON);

echo $person->name; // Johny Carson
Posted by: Guest on July-01-2019
79

javascript json decode

var jsonPerson = '{"first_name":"billy", "age":23}';
var personObject = JSON.parse(jsonPerson); //parse json string into JS object
Posted by: Guest on July-23-2019
12

javascript parse json

const json = '{ "fruit": "pineapple", "fingers": 10 }';
const obj = JSON.parse(json);
console.log(obj.fruit, obj.fingers);
Posted by: Guest on May-20-2020
2

json_decode javascript

JSON.parse(jsonToDecode)
Posted by: Guest on June-24-2020
2

json_encode json_decode php examples

json_encode used when PHP retrieve data and convert Array() to [] !!!!
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
echo json_encode($arr);
//output
{"a":1,"b":2,"c":3,"d":4,"e":5}
access from js file data.a, data.b,data.c...
----------------------------------------------
  $json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
json_decode($json, true); //true turns object to associative array;

//output
array(5) {
    ["a"] => int(1)
    ["b"] => int(2)
    ["c"] => int(3)
    ["d"] => int(4)
    ["e"] => int(5)
}
Posted by: Guest on July-26-2020
1

JSONDecoder

struct GroceryProduct: Codable {
    var name: String
    var points: Int
    var description: String?
}

let json = """
{
    "name": "Durian",
    "points": 600,
    "description": "A fruit with a distinctive scent."
}
""".data(using: .utf8)!

let decoder = JSONDecoder()
let product = try decoder.decode(GroceryProduct.self, from: json)

print(product.name) // Prints "Durian"
Posted by: Guest on May-22-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language