List of Dictionary of item to single item.

Certified Senior Developer

Hi Team,

Can someone provide insights of QueryEntity rule returning List of Dictionary even though we are returning only one row.

Our response is allways only one row. how to get as a single object instead of List.

Thanks in advance.

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    As far as Query Entity knows, it will always (possibly) return an array, whether or not your filtering conditions indicate that only a single row will be returned.  Therefore it always returns an array even if it's just an array of 1 (or 0).

    If you're confident that your QE rule will return 1 and only 1 result, and not 0, then you can simply put "[1]" after ".data" to return a single dictionary.  Alternatively, you can cast the result as the (single) data type you're using, which will have a similar effect.

Reply
  • +1
    Certified Lead Developer

    As far as Query Entity knows, it will always (possibly) return an array, whether or not your filtering conditions indicate that only a single row will be returned.  Therefore it always returns an array even if it's just an array of 1 (or 0).

    If you're confident that your QE rule will return 1 and only 1 result, and not 0, then you can simply put "[1]" after ".data" to return a single dictionary.  Alternatively, you can cast the result as the (single) data type you're using, which will have a similar effect.

Children
No Data