Unable to read JSON data

Hi I have get request like below

this.http.get(url,{}).subscribe(data=>{
console.log(data);
this.jsonData=JSON.stringify(data);
console.log("data is " + this.jsonData.responce);
var result = this.jsonData.responce;
});

am able to get data like below

  1. {tetra_PORT: “8081”, Email: “xxxx@yyy.com”, server_PORT: “8888”, response: “success”, tetra_IP: “221.222.22.222”, …}

  2. Email: “ssss@aaaa.com

  3. response: “success”

  4. server_IP: “111.111.11.111”

  5. server_PORT: “8888”

  6. tetra_IP: “111.111.11.111”

  7. tetra_PORT: “8888”

  8. users: (357) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…},

am unable to read data.
How to read data please guide me.

Can you please explain your issue as how you want to display the data or your are getting any error.

am not getting any error. It is printing data in console but am unable to read data.

beow is my response

{

“tetra_PORT”: “8888”,

“Email”: “sssss@sssss.com”,

“server_PORT”: “8888”,

“response”: “success”,

“tetra_IP”: “111.111.11.111”,

“server_IP”: “111.111.11.111”,

“users”: [

{

“name”: “AAAAAA BBBBB”,

“checked”: false,

“email”: null

},

{

“name”: “CCCCC DDDDD”,

“checked”: false,

“email”: null

}]
}

So I want to read this data. It is not allowing to read as per my above code.

Please describe what to you mean with “read” the data. When your app prints out the response to the console, where is the problem?

1 Like

Hi,Ok in my question, Check the line for

var result=this.jsonData.responce;

it is giving undefined, I want to access responce value, based on that responce I want to do further operations . etc.

what happens when you try to log out the parsed JSON jsonData?

means, I am not getting.

this.http.get(url,{}).subscribe(data=>{
console.log(data);
this.jsonData=data;
console.log("data is " + this.jsonData.responce);
var result = this.jsonData.responce;
});

No you are trying to log out jsonData.responce, but in your actual response i see only an field response. So you might have a typo here? responce instead of response?

if you get direct JSON data from the server then why we have to stringify JSON again in response

you don’t have to parse it

Try to commpent out all in the then() Block and only log out:

console.log(data.response);

Yes, It is working. Thanks both of you. I did stupid mistake.

Thank you soo much. It is working now.

Can you guide me implementing for emoji’s keyboard for a chat application?

Please check this Query