0

I have q requirement where I receive a JSON input and display it. Whenever I click on any value of the JSON, I need to get all parent keys in sequence.

Below is the sample JSON

{
  "response": {
    "Location": [{
      "Name": "New York, NY",
      "Point": {
        "Latitude": "40.714550018310547",
        "Longitude": "-74.007118225097656"
      },
      "BoundingBox": {
        "SouthLatitude": "40.36376953125",
        "WestLongitude": "-74.745925903320312",
        "NorthLatitude": "41.056510925292969",
        "EastLongitude": "-73.267219543457031"
      },
      "EntityType": "PopulatedPlace",
      "Address": {
        "AdminDistrict": "NY",
        "CountryRegion": "United States",
        "FormattedAddress": "New York, NY",
        "Locality": "New York"
      },
      "Confidence": "High",
      "MatchCode": "Good",
      "GeocodePoint": {
        "Latitude": "40.714550018310547",
        "Longitude": "-74.007118225097656",
        "CalculationMethod": "Rooftop",
        "UsageType": "Display"
      }
    }, {
      "Name": "New York, NY",
      "Point": {
        "Latitude": "40.714550018310547",
        "Longitude": "-74.007118225097656"
      },
      "BoundingBox": {
        "SouthLatitude": "40.36376953125",
        "WestLongitude": "-74.745925903320312",
        "NorthLatitude": "41.056510925292969",
        "EastLongitude": "-73.267219543457031"
      },
      "EntityType": "PopulatedPlace",
      "Address": {
        "AdminDistrict": "NY",
        "CountryRegion": "United States",
        "FormattedAddress": "New York, NY",
        "Locality": "New York"
      },
      "Confidence": "High",
      "MatchCode": "Good",
      "GeocodePoint": {
        "Latitude": "40.714550018310547",
        "Longitude": "-74.007118225097656",
        "CalculationMethod": "Rooftop",
        "UsageType": "Display"
      }
    }]
  }
}

Now, I have this key chain in json response → Location → Point → Latitude. Suppose I have a key Latitude and I want all its parent keys in a sequence, how do I get that?

Note: This is a sample JSON. Keep in mind that I will get JSON dynamically.

GôTô
  • 7,974
  • 3
  • 32
  • 43
allgood
  • 1
  • 3

0 Answers0