# String to object variable

**URL:** <https://forum.kirupa.com/t/string-to-object-variable/281951>\
**Category:** Uncategorized\
**Created:** [February 16, 2009, 1:43am UTC](https://forum.kirupa.com/t/string-to-object-variable/281951 "2009-02-16T01:43:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![leofish](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/leofish/32/3454_2.png) [@leofish](https://forum.kirupa.com/u/leofish)\
**Post date:** [February 16, 2009, 1:43am UTC](https://forum.kirupa.com/t/string-to-object-variable/281951/1 "2009-02-16T01:43:59Z")

</div>

I’m trying to format a variable into the middle of an object so that I can pass the entire thing as a parameter to a javascript function via ExternalInterface, but I cannot figure out how to format the data correctly.

I need it to end up looking like this:

```auto
{gallery:'myvar'}

```

braces and apostrophes included. myvar would be my variable data, which is a string. I tried connecting it all together as a big string, but the javascript function didnt like that. It did accept it if I typed the entire thing staticly as an object variable and passed that. Is there any way I can format it all into a string and then convert the string data to an object? or is there another way to try and accomplish something like this? thanks
