I have a response from a third party api as [object Object] now I want to parse the value of this object but not able to do that using JSOn.parse. Any idea how can I get the properties of object in JavaScript?
Asked
Active
Viewed 52 times
-1
-
What happens when you do JSON.parse() ? – pfcodes Oct 28 '18 at 05:50
-
Possible duplicate of [what does \[object Object\] mean?](https://stackoverflow.com/questions/4750225/what-does-object-object-mean) – jrook Oct 28 '18 at 05:51
-
@jrook it's not duplicate as the responses doesn't tell about how to get the values properties from object. – iAviator Oct 28 '18 at 05:52
-
Json.parse returns only bracket [ – iAviator Oct 28 '18 at 05:52
-
I didn't see any difference with the question I linked. Please edit your question to clearly state your problem, possibly with code samples and the steps you have taken so far to resolve the issue. You can also consult this guide: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects – jrook Oct 28 '18 at 05:54
-
The question is clear I just want to get the properties of an object if you have the answer then provide the appropriate link.The one you provide doesn't have the answer.i Don't think any code is required because the question is simple and is understood by others. – iAviator Oct 28 '18 at 05:57
-
@iAviator can you post your JSON value in the question? – Prashant Pimpale Oct 28 '18 at 06:28
1 Answers
0
Below will help you out to iterator through each Key-item of your any depth data in javascript. This is for properties.
<script>
var obj = {
lang: "php",
popularity: "80",
complexity: {
syntax: "simple",
oop: "supported",
orm:"available",
desktop:false
}
}
for(var propt in obj){
if (typeof(obj[propt]) === 'object'){
myIterator(obj[propt]);
}else{
alert(propt + ': ' + obj[propt]);
}
}
function myIterator(myData){
for(var propt in myData){
alert(propt + ': ' + myData[propt]);
if (typeof(myData[propt]) === 'object'){
myIterator(myData[propt]);
}
}
}
</script>

Patel Nikhil
- 185
- 6
-
It is too complex.Isn't there any vanilla js method that return all the properties of an object? – iAviator Oct 28 '18 at 06:03
-
above is concept understanding on basics for Framework based solution you should go through below articles hope that will help you https://codybonney.com/how-to-iterate-over-an-object-in-javascript/ and http://www.competa.com/blog/loop-object-vanilla-javascript/ – Patel Nikhil Oct 28 '18 at 06:10