NatureShade
NatureShade

Reputation: 2237

Convert variable into json path

I have a dynamically changing variable from hash with a joint of a json path.

Example:

$(function() {
    $(window).bind( 'hashchange', function() {
        var hash = window.location.hash.substring(1);
        $("#display_content").html(position.hash);
    });
    $(window).trigger( 'hashchange' );
});

How is it posible to turn the hash variable into a joint of the json url?


Edit:

By joint i mean a part of a json url: (position.secondposition.content) so each part seperated by a . is a joint.

Upvotes: 2

Views: 915

Answers (1)

Satpal
Satpal

Reputation: 133403

You can use position[hash]

So change your code as

 $("#display_content").html(position[hash]);

Upvotes: 3

Related Questions