Skip to main content
Question

Extract values from a complex json file

  • May 29, 2019
  • 4 replies
  • 137 views

mda
Contributor
Forum|alt.badge.img+7
  • Contributor
  • 19 replies

Hi,

@takashi

I am getting a json file out of a http call. This json is very big and there are many nested values. I need to get some certain values from this json. For example, I need to get the "OTXMP_GPSLatitude". This GPS latitude value is existing many times in the json. I tried to extract this value using many json extraction querys but I get an empty attribute. Some of the json querys I used are : (json["data"]["regions"][*]["OTXMP_GPSLongitude"], or json[*]["OTXMP_GPSLatitude"]). I will attach the json file. I hope that someone can help me getting all the coordinates from this json by one request or json extraction.

Thanks in advance,

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

takashi
Celebrity
  • 7843 replies
  • May 29, 2019

I think you can use the JSONFragmenter with this query expression to extract every "regions" object as JSON fragment,

json["results"][*]["data"]["regions"]

then use the JSONExtractor with these expressions extract latitude/longitude from each fragment.

json["OTXMP_GPSLatitude"]

json["OTXMP_GPSLongitude"]


mda
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • 19 replies
  • May 29, 2019

Thanks a lot @takashi. I was mistaken by the place of [*]. Your solution works good. :)

Regards,,

Muhammed


danilo_fme
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • 2077 replies
  • May 29, 2019

I think you can use the JSONFragmenter with this query expression to extract every "regions" object as JSON fragment,

json["results"][*]["data"]["regions"]

then use the JSONExtractor with these expressions extract latitude/longitude from each fragment.

json["OTXMP_GPSLatitude"]

json["OTXMP_GPSLongitude"]

Nice Job @takashi


mda
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • 19 replies
  • May 29, 2019

@takashi After knowing the right place for the [*], now I can get the specific values I need directly from the jsonExtractor without using jsonFragmenter for example by using the following query expression

json["results"][*]["data"]["regions"]["OTXMP_GPSLatitude"]

or using a similar expression to extract the ids as following:

json["results"][*]["data"]["properties"]["id"]

 

Thanks again Takashi :)

 

Regards,,

Muhammed