var str = 'hello'; var json = {}; json[str] = 'wassup'; alert(json.hello);
Ask google about dot and square bracket notations for more info. On 10 мар, 08:15, "gordiany...@gmail.com" <gordiany...@gmail.com> wrote: > var str = "hello"; > var json = { > str: "123" > > } > > I know this is not jquery question , but I don't know where I should > go > The question is how can I use VAR str into json object, I don't want > {"str": 123}, actually i want {"hello": 123} > How can solve this problem? In fact this question troubling me a long > time > Thank you for the answer, any input will help