0

I have a json here - Returning rows of a search result

"rows": [
                    {
                        "uid": "t091_13213131331",
                        "id": "12414_0214124214",
                        "cells": [
                            {
                                "id": "name",
                                "values": [
                                    {
                                        "value": "Some value",
                                        "displaytxt": "Some text"
                                    }
                                ]
                            },
                            {
                                "id": "status",
                                "values": [
                                    {
                                        "value": "Some value",
                                        "displaytxt": "Some text"
                                    }
                                ]
                            },
                            {
                                "id": "date",
                                "values": [
                                    {
                                        "value": "Some value",
                                        "displaytxt": "Some text"
                                    }
                                ]
                            },
                            {
                                "id": "proj",
                                "values": [
                                    {
                                        "id": "123_121314124",
                                        "value": "Some value",
                                        "displaytxt": "Some text"
                                    }
                                ]
                            },
                            {
                                "id": "documents",
                                "values": [
                                    {
                                        "id": "123_121314124",
                                        "value": "Some value",
                                        "displaytxt": "Some text"
                                    },
                                    {
                                        "id": "123_121314122",
                                        "value": "Some value",
                                        "displaytxt": "Some text"
                                    },
                                    {
                                        "id": "123_12325314124",
                                        "value": "Some value",
                                        "displaytxt": "Some text"
                                    },
                                    {
                                        "id": "1236_8314124",
                                        "value": "Some value",
                                        "displaytxt": "Some text"
                                    }
                                ]
                            }
                        ]
                    }
]

Now I have to check the id value that matches the value "status" and if that it matches a certain value, then I have to check the value of values -> value. If that also matches the value I need then I need to return the entire entry (all ids that matches name, status, date - basically that array element of the cells array.)

I am looking for the logic and tried iterating inside the cells array and checking the status but when I tried filtering, the output had only this

                            {
                                "id": "status",
                                "values": [
                                    {
                                        "value": "Some value",
                                        "displaytxt": "Some text"
                                    }
                                ]
                            }

The response I want -

                            {
                                "id": "name",
                                "values": [
                                    {
                                        "value": "Some value",
                                        "displaytxt": "Some text"
                                    }
                                ]
                            },
                            {
                                "id": "status",
                                "values": [
                                    {
                                        "value": "Some value",
                                        "displaytxt": "Some text"
                                    }
                                ]
                            },
                            {
                                "id": "date",
                                "values": [
                                    {
                                        "value": "Some value",
                                        "displaytxt": "Some text"
                                    }
                                ]
                            },
                            {
                                "id": "proj",
                                "values": [
                                    {
                                        "id": "123_121314124",
                                        "value": "Some value",
                                        "displaytxt": "Some text"
                                    }
                                ]
                            },
                            {
                                "id": "documents",
                                "values": [
                                    {
                                        "id": "123_121314124",
                                        "value": "Some value",
                                        "displaytxt": "Some text"
                                    },
                                    {
                                        "id": "123_121314122",
                                        "value": "Some value",
                                        "displaytxt": "Some text"
                                    },
                                    {
                                        "id": "123_12325314124",
                                        "value": "Some value",
                                        "displaytxt": "Some text"
                                    },
                                    {
                                        "id": "1236_8314124",
                                        "value": "Some value",
                                        "displaytxt": "Some text"
                                    }
                                ]
                            }
  • I can't really understand. What *more* than the entry that you have currently filtered out would you like to get? – mortb Apr 25 '22 at 07:17
  • The rows array usually contain multiple elements. I have given a json with just one. So I want to dig into the json and look into the value of the entry with id status. If say the value is Done, I want the entire array element to be returned (including those with ids - name, proj, date) and not just the element with the id status.. – Krishna Krish Apr 25 '22 at 07:28

0 Answers0