Get Array Elements By Name RRS feed

  • Question


    I was wondering if it is possible to get the elements of a json array by the name of the property than the position. Consider this data:

        "salesdata": {
            "productsbyzone": {
                "zones": [{
                        "eastzone": "shirts, trousers"
                        "westzone": "slacks"
                        "northzone": "gowns"
                        "southzone": "maxis"

    I intend to get the values for each zone by the name of the zone rather than the position. I was able to successfully run the following stream analytics query until I realized that the position of the zones differs in each json that I receive.

    salesData AS
        (,0) as eastzone,
        (,1) as westzone,
        (,2) as northzone,
        (,3) as sourthzone,
        FROM [sales-data] as c
    eastzone.eastzone as PRODUCTS_EAST,
    westzone.westzone as PRODUCTS_WEST,
    northzone.northzone as PRODUCTS_NORTH,
    southzone.southzone as PRODUCTS_SOUTH
    FROM salesData 

    Need a way to retrieve the values by the name rather than the position of the array element. Thanks in advance.

    Sunday, February 11, 2018 7:22 AM

All replies

  • The best solution would be to write custom JavaScript function. You can see similar example in this blog entry:
    Monday, February 12, 2018 8:10 PM
  • Tis will help

    Thursday, May 17, 2018 2:51 PM