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: 
jeremyk
Level 7

Sample code for JSON and is it faster?

I was wondering if anyone had some sample code that uses JSON instead of XML. Also curious if it is faster or slower on the Roku box. I would love to see a port of the videoplayer example code if it is indeed quicker.

Thanks in advance!
0 Kudos
2 REPLIES 2\
TheEndless
Level 10

Re: Sample code for JSON and is it faster?

There is no native JSON parsing in BrightScript. A couple of us have worked on JSON libraries (do a search in this forum), but none are faster than XML, if that's an option.
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: Sample code for JSON and is it faster?

As someone that did quite a bit of work on JSON encode/decode functions for the Roku, I can state it's quite a bit slower than XML procesing. This is due to it replying heavily on BrightScript processing instead of an underlying C/C++ library exposed through a component.

Depending on the size of the JSON, it may be fast enough for you though, so feel free to take a look: https://github.com/rokudev/librokudev/b ... rdJSON.brs (requires rdSerialize from the same project).
That implementation makes heavy use of regular expressions to normalize the JSON into something that can be parsed as native BrightScript, and then evals it. It's fairly quick by BrightScript standards, but still quite slow on large sets of data.

See https://github.com/rokudev/librokudev for more information about the librokudev project itself, or search these forums.
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos