0

How to parse and use JSON

Hi,

since I'm new to this...I've allready studied the documentation but there are thinks that are still very unclear for me.

Since there is no funvtionalyt as is for parsing JSON files I need to write a parser plugin. There is an example how this sould look like, is the example usabel as such a plugin?
If so, an we would use this exact example, what du I have to set for the "Function Names"? (Feed parser, User Agent String, User Variable Parser)?

How do I get the values from the JSON to a text on screen after that? User variables?
How do I set up, that the json should be checkt for changes every  5min?

For RSS/MRRS this seemst to be implemented in Bright Author right away...
Sory for my questions but im not such a code-guy...

Thanks!

8 comments

  • 0
    Avatar
    JRB Technical

    I think you might be confusing JSON, XML, and RSS/Media RSS.

    JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is currently the common format for Data API's.

    XML (Xtensible Markup Language) is a markup language much like HTML. XML was designed to store and transport data.

    RSS (Really Simple Syndication) and Media RSS are both a dialect of XML. ALL RSS files must conform to the XML specification. This has long been the Standard for all RSS feeds, including Media RSS.

    If you want to use JSON data, you really need to Parse it yourself using your own service (on a separate server, not on the Player) to convert it to an XML format that BrightSign/BrightAuthor can easily read and use. This is what I do, and many others as well.

    Unfortunately parsing API Data can easily become very complex, with too many variable aspects to be easily handled by the player. For most of the Data I have worked with, I have had to add many conditionals to handle things that are much easier to handle with a full programming language then with BrightScript.  

    One subset of my Weather API scripts is already over 2500 lines of code just for the main module.

    BrightScript can do a lot, and is able to deal with some JSON formatted strings, but it is really not best suited to easily work with JSON at this time.

     

  • 0
    Avatar
    Markus Funke

    Hi,

    since there is a JSON Parser Funktion in BSscript I supose it can't be very difficult to get a parser working.
    The datafile I get from my client has only 8 values, so it is not that big.
    Problem is, there is no way at the moment to use any other data format or a pc that translates the data...

  • 0
    Avatar
    Markus Funke

    Our costumer now changed to plain XML.
    Is there any advice,when I need to use xml as base? Since RSS is XML based using the data should be easyer?

  • 0
    Avatar
    Bright Scripters

    In some cases, presenting information from XML is straight forward, and in other cases, a parser is required.

    Could you share more info about your application?

    Please describe what type of information you are trying to present, and how.

     

  • 0
    Avatar
    Markus Funke

    Well it seems to work now, but I only get the data in Bright Author, not on the player (see my other post) :-(

  • 0
    Avatar
    krt

    Hi!

    I have Barco, HD233 and XT1143. 

    Barco uses JSON RPC. 

    The purpose is to control Barco's shutter. 

    The command for it is:

    {

    "jsonrpc": "2.0",

    "method": "optics.shutter.toggle",

    "id": 310,

    "params": {}

    }

     

    How can it be converted for Brightsign?

  • 0
    Avatar
    krt

    Solved.

  • 0
    Avatar
    Bernd Strobl

    How did you solve it krt?

Please sign in to leave a comment.