0
var data = {
    "DYNAMIC_KEY/VALUE_A":{
        "DYNAMIC_KEY/VALUE_1":{
            "key_1":"value_1",
            "key_2":"value_2",
            "key_3":"value_3"
        },
        "DYNAMIC_KEY/VALUE_2":{
            "key_1":"value_1",
            "key_2":"value_2",
            "key_3":"value_3"
        },
        "DYNAMIC_KEY/VALUE_3":{
            "key_1":"value_1",
            "key_2":"value_2",
            "key_3":"value_3"
        }
    },
    "DYNAMIC_KEY/VALUE_B":{
        "DYNAMIC_KEY/VALUE_1":{
            "key_1":"value_1",
            "key_2":"value_2",
            "key_3":"value_3"
        },
        "DYNAMIC_KEY/VALUE_2":{
            "key_1":"value_1",
            "key_2":"value_2",
            "key_3":"value_3"
        },
        "DYNAMIC_KEY/VALUE_3":{
            "key_1":"value_1",
            "key_2":"value_2",
            "key_3":"value_3"
        }
    }
}

alert(data[DYNAMIC_KEY/VALUE_A[DYNAMIC_KEY/VALUE_1].key_1]);

alert(data[DYNAMIC_KEY/VALUE_A][DYNAMIC_KEY/VALUE_1]["key_1"]);

I tried several solutions, but it did not !

Could someone explain me how to proceed ? Thanks :)

1
  • Your question doesn't make much sense. What does "get value from dynamic key/value into dynamic key/value" mean? Can you provide us with an example of the output you want? Commented May 12, 2015 at 11:20

2 Answers 2

1

you can use

alert(data['DYNAMIC_KEY/VALUE_A']['DYNAMIC_KEY/VALUE_1']['key_1']);

DEMO

Sign up to request clarification or add additional context in comments.

Comments

1

There are special symbols(/) in keys of data object. This is the reason your code is not working.

To get value from this object, the key must be used as subscript.

alert(data["DYNAMIC_KEY/VALUE_A"]["DYNAMIC_KEY/VALUE_1"].key_1);

OR for key_1 you can also use subscript [] notation.

alert(data["DYNAMIC_KEY/VALUE_A"]["DYNAMIC_KEY/VALUE_1"]["key_1"]);

Check in docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.