Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
Trader5050
Level 7

LibRokuDev JSON & RegWrite/Read error

Hello again,

I'm having an odd problem.

I'm encoding an associativeArray into a JSON string using the librokudev GITHUB repository for storage into the registry. It looks like this:

Data = {
name: Cam
refresh: 1
url: http://somelongurl
title: Cam
randomize: YES
}

which is serialized into this string:
{"name":"Cam","refresh":"1","url":"http://somelongurl","title":"Cam","randomize":"YES"}

Later, I read this back out of the registry, parse it, and allow the user to edit it and save it again. The problem is that when it's re-saved, despite the "print" of the array LOOKING right, it now serialize's to this:
{"name":"String","refresh":"String","url":"String","title":"String","randomize":"String"}

Something weird is happening when data that looks just fine is re-encoded using the rdSerialize() function of librokudev. (using "JSON" option) The only thing I'm doing to the associative array before saving is calling "rdJSONBuilder(data)" (which simply calls rdSerialize(data,"JSON") )

Any ideas?
0 Kudos
5 Replies
TheEndless
Level 7

Re: LibRokuDev JSON & RegWrite/Read error

Why are you using LibRokuDev for JSON parsing and formatting instead of the native ParseJson and FormatJson functions (http://sdkdocs.roku.com/display/sdkdoc/BrightScript+Language+Reference#BrightScriptLanguageReference...)? The first thing I'd do is switch to the native functions and see if that fixes the issue for you.
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
kbenson
Level 7

Re: LibRokuDev JSON & RegWrite/Read error

That's interesting. I think I'll actually be doing some work on the Roku in the near future, so I'll try to take a look and see what's happening and try to fix it.

That said, if Roku now provides a native JSON serialization method, that's likely much better than the one implemented in librokudev, which is somewhat hacky.

If anyone has any requests, comments or suggestions for librokudev, please let me know.
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos
TheEndless
Level 7

Re: LibRokuDev JSON & RegWrite/Read error

"kbenson" wrote:
That's interesting. I think I'll actually be doing some work on the Roku in the near future, so I'll try to take a look and see what's happening and try to fix it.

That said, if Roku now provides a native JSON serialization method, that's likely much better than the one implemented in librokudev, which is somewhat hacky.

If anyone has any requests, comments or suggestions for librokudev, please let me know.

Hey kbenson! Long time, no rearing of your head!
Unless I'm mistaken, I believe the librokudev JSON implementation was actually based on our collaborative Roku forum efforts several years ago (read: my appallingly bad regex, and your refinements), so I have decided to take offense to your "somewhat hacky" comment, even if it is accurate! Smiley Wink
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
kbenson
Level 7

Re: LibRokuDev JSON & RegWrite/Read error

"TheEndless" wrote:
Hey kbenson! Long time, no rearing of your head!


Yeah, I lurk every few months with a few specific searches to see if I've been called out or anyone's mentioned any of my pet projects, but generally that doesn't happen often.

...but Roku contacted me recently re: RAF, and the numbers look interesting enough that I'm intrigued. So maybe I'll be a bit more involved for a while. Smiley Happy

"TheEndless" wrote:

Unless I'm mistaken, I believe the librokudev JSON implementation was actually based on our collaborative Roku forum efforts several years ago (read: my appallingly bad regex, and your refinements), so I have decided to take offense to your "somewhat hacky" comment, even if it is accurate! Smiley Wink


Well, it works most of the time, and was generally much faster than the tokenizing parser that was posted around the same time, so I'd say we all did pretty good. But it's still using regular expressions to parse JSON... so yeah, hacky. Smiley Wink
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos
EnTerr
Level 8

Re: LibRokuDev JSON & RegWrite/Read error

I think his beef was with "somewhat", not with "hacky" :twisted:
0 Kudos