Graphics

 View Only
  • 1.  Filtering and sorting JSON feed - Datalinq

    Posted 10-18-2022 03:45
    Hello everyone,

    I have 3 score text fields that will be Datalinqed to a JSON file containing scores plus other info.

    Each score has a flag to determine if is a valid score (top 3) or not. The scores are not sorted in numeric value order. They are sorted in the order that they got scored, over the time of the heat.

    The two challenges I have:
    - Filter through the feed and isolate the only 3 scores that have a "valid" flag
    - Sort the 3 scores in numerical order (highest to lowest)

    Is it something that is possible to achieve this in the Datalinq configuration or does it have to be visual logic or scripting?

    Note: The score bug will be online and the changes would have to happen live on air, once scores are populated.

    Thank you!

    ------------------------------
    Paulo Dias
    ------------------------------


  • 2.  RE: Filtering and sorting JSON feed - Datalinq

    Ross Staff
    Posted 10-18-2022 14:49

    Hey Paulo

    You can search json files the same way as XML I think so here's an example. 

    Column: teams\teamsMatch<2>\teamLineup\teamPlayer<shirtNum=%Jersey%>
    Row: playerId
    Table: @DataCompetition@

    In this example I know that the team I want is number 2 because that was away so I what \teamsMatch<2>, \teamsMatch<1> would be Home. 
    Probably more interesting to you is the later part which is teamPlayer<shirtNum=%Jersey%> this will return the teamPlayer which is a name where his shirt number shirtNum equals a datalinqkey value I am sending later. 
    The Row is fixed in this case however the Table is set but a text macro that the operator can choose to change the league in the this example. 

    Now regarding sorting them in numerical order, I know with tables you can use a query like;
    SELECT * FROM [Table] ORDER BY [Column] ASC/DESC 
    but I am not sure for XML or JSON

    You could try using the sort selection block but if you have a lot of score values that could be a lot of work.  

    In my head I have the idea for a loop that might work, it would go through and check each value and see if it was higher than the previous and write it to the object if it's true and do that x3 but I'm sure a better script writer could do something better. 



    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------