-
Notifications
You must be signed in to change notification settings - Fork 0
/
index2.html
37 lines (33 loc) · 1.14 KB
/
index2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Json</title>
</head>
<body>
<script>
var myObj = {"name":"john", "age":31, "city":"Ankara"};
var myJson = JSON.stringify(myObj);
console.log(myJson);
// send JSON gönderme biçim
//window.location ="demo_json.php?x=" + myJSOn;
//JSON.parse reviver canlandırma
var text = '{"name":"john","age":"39","city":"Toronto"}';
var obj = JSON.parse(text,function (key,value){
if(key=="city"){
return value.toUpperCase();
}else{
return value;
}
});
console.log(obj.city)
// sunucudan alınan JSON ayrıştırılıyor
//JSON:stringfy() yöntemi javascirpt nesneleri dizelere dönüştürür
//JSON.stringfy(obj,replacer,space) space yaniii boşluk paremeteresi örnek
var obj = {"name":"faruk","age":"25","city":"Toronto"};
var text = JSON.stringify(obj,null,"SPACE");
console.log(text);
</script>
</body>
</html>