jeremyk
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2011
12:50 PM
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!
Thanks in advance!
2 REPLIES 2

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2011
12:59 PM
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)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
kbenson
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2011
04:40 PM
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.
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!
Check out Reversi! in the channel store!