Access a JSON chain with Javascript, Node.JS and Watson

0

I have this result in JSON that I receive from IBM Watson:

{
  "document_tone": {
    "tones": []
  }
}

This result, I keep it inside a variable in Javascript. My question is: How can I put a condition in Javascript, so that each time I get that result, in the console I put: "Empty results"?

Thank you very much!

    
asked by Isaac Alejandro 13.09.2018 в 17:05
source

1 answer

0

If you are referring to empty results by the "tones" index, you can do so

var json = Respuesta_IBM_Watson();
if( json.document_tone.tones.length === 0 ){
   console.log( 'está vacio' );
}

else{
  //Otras cosas
}
    
answered by 13.09.2018 / 17:12
source