Alert Json object

后端 未结 4 1435
别那么骄傲
别那么骄傲 2021-02-02 07:43

I have the following json object i need to alert it through javascript.

{data:[{\"empmenuid\":\"1\",\"empid\":null,\"deptid\":\"66\",\"aliasid\"         


        
相关标签:
4条回答
  • 2021-02-02 08:27
    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.????? ) ;
    
    0 讨论(0)
  • 2021-02-02 08:35

    You can access a JSON objects properties using the dot operator:

    var person {
       "name":"test",
       "age":20    
    }
    
    //document.write(person.name);
    alert(person.name);
    
    0 讨论(0)
  • 2021-02-02 08:42

    Use console.log instead

    0 讨论(0)
  • 2021-02-02 08:44

    Just use

    alert(JSON.stringify(your_json_obj));
    
    0 讨论(0)
提交回复
热议问题