반응형
Alert Json 개체
jascript를 통해 경고할 필요가 있는 json 오브젝트는 다음과 같습니다.
{data:[{"empmenuid":"1","empid":null,"deptid":"66","aliasid":"66","firstname":"66","lastname":"66","sin":"66","status":"66","empclass":"66","hiredate":"66","seneoritydate":"66","separationdate":"66","recalldate":"66","martialstatus":"66","gender":"66","ethinicorigin":"66","ethinicsuborigin":"66","nationality":"66","address1":"66","address2":"66","city":"66","province":"66","postalcode":"66","country":"66","email":"66","officialemail":"66","phone":"66","otherphone":"66","fax":"66","officephone":"66","officeext":"66","officefax":"66","mobilephone":"66","pager":"66","locid":"66","jobtitle":"66","jobtitlestart":"66","fullpart":"66","manager":"66","managername":"66","middlename":"66","nickname":"66","paytype":"66","payfreq":"66"},{"empmenuid":"3","empid":null,"deptid":"12","aliasid":"12","firstname":"12","lastname":"12","sin":"12","status":"12","empclass":"12","hiredate":"12","seneoritydate":"12","separationdate":"12","recalldate":"12","martialstatus":"12","gender":"12","ethinicorigin":"12","ethinicsuborigin":"12","nationality":"12","address1":"12","address2":"12","city":"121","province":"12","postalcode":"12","country":"12","email":"12","officialemail":"12","phone":"12","otherphone":"12","fax":"12","officephone":"12","officeext":"12","officefax":"12","mobilephone":"12","pager":"12","locid":"12","jobtitle":"12","jobtitlestart":"12","fullpart":"12","manager":"12","managername":"12","middlename":"12","nickname":"12","paytype":"12","payfreq":"12"}],
recordType : 'object'}
그냥 사용하다
alert(JSON.stringify(your_json_obj));
를 사용하여 JSON 개체 속성에 액세스할 수 있습니다.dot연산자:
var person {
"name":"test",
"age":20
}
//document.write(person.name);
alert(person.name);
대신 console.log 사용
경보 팝에서 적절하게 정형화된 데이터를 보려면 한 가지 방법을 사용할 수 있습니다.
alert(JSON.stringify(YOUR_OBJECT_HERE, null, 4));
문자열화된 객체가 있는 경우
alert(JSON.parse(JSON.stringify(STRIGYFIED_DATA, null, 4)));
var obj = [
{
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "Sincere@april.biz",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
"zipcode": "92998-3874",
"geo": {
"lat": "-37.3159",
"lng": "81.1496"
}
},
"phone": "1-770-736-8031 x56442",
"website": "hildegard.org",
"company": {
"name": "Romaguera-Crova",
"catchPhrase": "Multi-layered client-server neural-net",
"bs": "harness real-time e-markets"
}
},
{
"id": 2,
"name": "Ervin Howell",
"username": "Antonette",
"email": "Shanna@melissa.tv",
"address": {
"street": "Victor Plains",
"suite": "Suite 879",
"city": "Wisokyburgh",
"zipcode": "90566-7771",
"geo": {
"lat": "-43.9509",
"lng": "-34.4618"
}
},
"phone": "010-692-6593 x09125",
"website": "anastasia.net",
"company": {
"name": "Deckow-Crist",
"catchPhrase": "Proactive didactic contingency",
"bs": "synergize scalable supply-chains"
}
}];
alert( obj.????? ) ;
언급URL : https://stackoverflow.com/questions/3466356/alert-json-object
반응형
'programing' 카테고리의 다른 글
| WooCommerce Order API는 항상 빈 주문을 만듭니다. (0) | 2023.03.14 |
|---|---|
| 리액트 훅 - 변수와 useState 사용 (0) | 2023.03.14 |
| 어떤 입력이 골랑의 json을 발생시키는지.오류를 반환할 보안요원? (0) | 2023.03.14 |
| WordPress "wp_register_style이 잘못 호출되었습니다?" (0) | 2023.03.14 |
| my.cnf에 대한 Mysqltuner 제안 및 변경 사항 (0) | 2023.03.14 |