-2

In my code one of the promise returning the result like this

[{"success":true,"fileName":"./tmp/test.txt"}]

and I want to convert it into Json. how to convert it? output:-{"success":true,"fileName":"./tmp/test.txt"}

Tanvi Shah
  • 497
  • 2
  • 9
  • 18

1 Answers1

0

You receive an array containing one object. Just access array's first element, like :

var array = [{"success":true,"fileName":"./tmp/test.txt"}];
var fileName = array[0].fileName;
Léo Martin
  • 736
  • 7
  • 13