1
Having a JSON of the type: {"HOME":{"INTRODUCAO":"midias/video1.mp4"}}
How to get the value midia/video1.mp4
from the string
var key = "HOME.INTRODUCAO";
I’ve tried to:
var key = "HOME.INTRODUCAO";
$.getJSON([CAMINHO DO JSON], function(j){
alert(j.key);
});
But I get the message "Undefined".
Have you tried using JSON.parse()? Ex: j = JSON.parse(j); Alert(j. key);
– web_dev
Hello, unfortunately when I try to parse I only get the first letter of the string. But vlw!
– Paulo Marcos Soares Rodrigues
Hello Paulo! Where does this JSON come from? It is a string yet or object?
– Sergio
Hello Sergio, JSON is in a separate file. my variable "key" I get it like this: var key= $("#test"). attr('video');
– Paulo Marcos Soares Rodrigues
Paul, okay and what gives if fiseres
console.log(typeof key, key);
after that line you indicated?– Sergio
Hello Sergio, I did like this: var key=$("#test"). attr('video'); console.log(typeof key, key); I got it from the console: "string HOME.INTRODUCTION".
– Paulo Marcos Soares Rodrigues