Accessing a JSON with JS

0

I was trying to access a JSON with JS, here is an example of how they are:

{
  status: "0",
  ano: "Não Informado",
  competencia: "Não Informado",
  id_Publication: "8"
}

But in fact this is only part of the full JSON. This is " a multidimensional array ". How can I access the information within p , specifically the competency part?

I've tried using this code:

{
  targets: 7,
  data: "",
  render: function(data, type, full){
    returnconsole.log(full);
  }
}

It returns the entire JSON if you use it this way and put it:

{
  targets: 7,
  data: "",
  render: function(data, type, full){
    returnconsole.log(full['p']);
  }
}

It returns the data only from p, MAS if I try to put:

{
  targets: 7,
  data: "",
  render: function(data, type, full){
    returnconsole.log(full['p.competencia']);
  }
}

It returns undefined .

    
asked by anonymous 16.08.2017 / 21:34

1 answer

1

Just create an object of your% JSON myObj ={json aqui} and access it by the name of the object point attribute: myObj.competencia . Simple, easy and fast.

myObj = {status: "0", ano: "Não Informado", competencia: "Não Informado", id_Publication: "8"};

console.log(myObj.competencia)
    
16.08.2017 / 21:52