JavaScript JSON.parse JSON string in javascript [closed] json parse json stringify,json parse json array,json parse

Closed. This question is off-topic. It is not currently accepting answers.
Answer:1

Your JSON.parse call is working perfectly fine. However, once parsed, the tweet_object variable is an array of JS objects. If you try to convert an object to a string, the result is [object Object]. Try this in your console: ({} + ' ') (an object literal, concatenated with a space).

An array, on the other hand extends the base Object prototype (Object.getPrototypeOf(Object.getPrototypeOf([])) -> get the prototype, of the prototype of an array. The result is Object {}). When an array is coerced to a string, it has the same effect as [].join(','). Joining with a comma as delimiter.
This is what happens here. your alert is converting the array to a string, concatenating its values using comma's for delimiters. Because each value is an object, the only possible result is a string like the one you're getting: [object Object],[object, Object],....

To get at a specific value in this array of objects, do as you normally would in JS:

for (var i=0;i<tweet_object.length;++i) {
    console.log(tweet_object[i].id);//or alert
}

TL;TR

What is happening:

  1. alert(tweet_object) is passing an array to alert. Alert coerces the argument to a string
  2. Arrays are coerced to a string by concatenating all the values, using a comma as a delimiter
  3. Each value is an object literal, which yields [object Object] when coerced to a string. They are being coerced to strings because the containing array is being coerced to a string (alert).

These three points explain the output:

[object Object], [object Object],...
     /\       /\       /\
   object  delimiter  object

So what now?

There was a point in time where people used to litter their code with alert's and custom functions to traverse objects and output them in a meaningful way. Thankfully, those days are long gone, and we now just dump variables, regardless of their value to the console (console.log). The console can handle any JS type: strings, objects, functions, ... doesn't matter. If you want to know what an object looks like, just console.log it.
When debugging code, use the tools that give you the most information about the thing you want to inspect. String representations of values almost always fall short...

Answer:2

I believe everything actually works fine, just the alert() function can not present the json data correctly, try to use the console.log(json_tweet_data) instead.

When you call the alert(this.responseText) you are actually looking on the json string, not on the parsed JSON. Once you parse it the alert just can't display it any more.

Answer:3

I'm using a document structure like this render() { return ( <div className="MyComponent"> <ul className=""> {parseRecommendations(this.props.recommendations)} ...

I'm using a document structure like this render() { return ( <div className="MyComponent"> <ul className=""> {parseRecommendations(this.props.recommendations)} ...

  1. count checked checkboxes jquery
  2. count checked checkboxes google sheets
  3. count checked checkboxes javascript
  4. count checked checkbox excel
  5. count checked checkbox in php
  6. count checked checkbox using class in jquery
  7. count checked checkbox in angular 2
  8. count checked checkbox length jquery
  9. count checked checkbox in datagridview c#
  10. count checked checkboxes
  11. count checked checkboxes in gridview jquery
  12. count checked checkboxes in gridview c#
  13. count checked checkboxes in div jquery
  14. count checked checkboxes in datagridview vb.net
  15. count checked checkboxes vb.net
  16. count checked checkboxes in gridview javascript
  17. jquery count checked checkboxes by class
  18. js count checked checkboxes
  19. jquery count checked checkboxes by id
  20. count all checked checkboxes jquery

My Ajax function $.ajax({ type: "POST", contentType: 'application/json;charset=utf-8', dataType:'json', url: 'getSites', data: JSON.stringify(), ...

My Ajax function $.ajax({ type: "POST", contentType: 'application/json;charset=utf-8', dataType:'json', url: 'getSites', data: JSON.stringify(), ...

  1. when is data reliable
  2. when census data released
  3. when is data relevant
  4. when is data relational

I have little leaflet application where the app get geoJson objects from server, and display it, specially LineString. The json parser that i use on server side works properly. And the client side ...

I have little leaflet application where the app get geoJson objects from server, and display it, specially LineString. The json parser that i use on server side works properly. And the client side ...

  1. leaflet swap coordinates

This is my code,i don't know why case 0, and case 1 are not working? are there any responses for these levels? This is the output request received processing request request finished and response is ...

This is my code,i don't know why case 0, and case 1 are not working? are there any responses for these levels? This is the output request received processing request request finished and response is ...