Get specific JToken based on value

Hi Experts

I have a JSON array build like this:

{
    "ExcelColumns": [
                        {
                            "ExcelColumnName":  "EmpId",
                            "MappedColumnName": "Employee ID"
                        },
                        {
                            "ExcelColumnName":  "FName",
                            "MappedColumnName": "First Name"
                        },
                        {
                            "ExcelColumnName":  "LName",
                            "MappedColumnName": "Last Name"
                        }
                    ]
}

I need to lookup a value in ExcelColumnName (e.g. Fname) and return the value in MappedColumnName (First Name).

How can this be done?

Hi,

Hope the following sample helps you.

jo("ExcelColumns").Where(Function(j) j("ExcelColumnName").Value(Of String)="FName").Select(Function(j) j("MappedColumnName").Value(Of String)).First

Sample20230119-1L.zip (2.6 KB)

Regards,

1 Like

grafik
output: myJObject

optimistic retrieval:

As an alternate we can also bring it within Dictionary and have quick acces and check options:

Thank you both @Yoichi and @ppr it helped me solving what I needed.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.