-2

If I have one value in my JSON file and I want to extract some information from my JSON file , How I should do this?

"audio_services": "{\"node-input-audio_services1\":\"network addresses\",\"audio_ip_1\":\"ports\",\"audio_port_1\":\"media clock rate\"}",

imaginge in this code,I want to extract : "etwork addresses" , "ports" ,"media clock rate".

Sohi
  • 15
  • 4

1 Answers1

1

You can use the JSON.parse function to change your JSON string into an object.
You can then access the property of this object using the . accessor, or the bracket ([ ]) accessor.

let audioObject = "{\"node-input-audio_services1\":\"network addresses\",\"audio_ip_1\":\"ports\",\"audio_port_1\":\"media clock rate\"}";

let object = JSON.parse(audioObject);
console.log(object['node-input-audio_services1'], ',', object['audio_ip_1'], ',', object['audio_port_1']);
Nicolas
  • 8,077
  • 4
  • 21
  • 51