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!

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.

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.