Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jbrave
Level 8

Convert string to AA?

if I have a string that looks like this:

"{test:"west",best:"vest",apple:"fruit"}"

is there any easy way to convert to an Associative Array?

- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
6 REPLIES 6\
TheEndless
Level 10

Re: Convert string to AA?

If aaString is "{test:"west",best:"vest",apple:"fruit"}"

Eval("aa = " + aaString)
print aa
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
jbrave
Level 8

Re: Convert string to AA?

ahhh, thank you.

- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
jbrave
Level 8

Re: Convert string to AA?

Ok, this is embarrasing, but it turns out I didn't see the quotes, it isn't:

{tagname:"value",tagname1:"value"}

its {"tagname":"value","tagname1":"value"}

Any idea how to strip the quotes off the tagname so I can then get do the Eval ?

- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
TheEndless
Level 10

Re: Convert string to AA?

That's JSON. Take a look at the JSON parser that was discussed here awhile back and added to the rokudev library that GandK put together.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
jbrave
Level 8

Re: Convert string to AA?

Ah, ok, thanks. I think I might be able to force xml with a header. fingers crossed.

- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
jbrave
Level 8

Re: Convert string to AA?

well, the forced headers didn't work, but its simpleJSONParser to the rescue!

- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos