Skip to main content
deleted 148 characters in body
Source Link
JavierG
  • 541
  • 4
  • 10

Here's my problem: I've got a JSON-formatted response and want to match some variables over the response. I'm doing it using Cases:

JsonResponse := Import["https://reverse.geocoder.api.here.com/6.2/reversegeocode.json?&app_code=djPZyynKsbTjIUDOBcHZ2g&app_id=xWVIueSv6JL0aJ5xqTxb&gen=3&int=true&jsonAttributes=1&languages=it-it&maxresults=9&mode=retrieveAddresses&prox=43.605979206920594,13.513478915691394,100", "JSON"]

Points = Cases[JsonResponse, {___ "displayPosition" -> "{latitude" -> lat_,"longitude" -> long_ "}", "navigationPosition" -> "{{latitude" -> _Float, "longitude" -> _Float "}}", "mapView" -> "{bottomRight" -> "{latitude" -> _Float, "longitude" -> _Float "}", "topLeft" -> "{latitude" -> _Float, "longitude" -> _Float "}}", "locationId" -> _String, "locationType" -> "point", "address" -> "{city" -> _String, "label" -> _String, "country" -> _String, "county" -> county_, "state" -> state_, "street" -> st_, "houseNumber" -> num_, postalCode -> zip_ ___} -> {{lat, long} -> {st, num, zip, county, state}}, Infinity]

The code is a bit more complex, I extracted what may be useful to the problem. You won't match that pattern, I wrote it so you can get the point.

I need to make it consider the inner braces as part of the pattern to be matched (Mathematica parses them as meaning list, otherwise).

Here's my problem: I've got a JSON-formatted response and want to match some variables over the response. I'm doing it using Cases:

JsonResponse := Import["https://reverse.geocoder.api.here.com/6.2/reversegeocode.json?&app_code=djPZyynKsbTjIUDOBcHZ2g&app_id=xWVIueSv6JL0aJ5xqTxb&gen=3&int=true&jsonAttributes=1&languages=it-it&maxresults=9&mode=retrieveAddresses&prox=43.605979206920594,13.513478915691394,100", "JSON"]

Points = Cases[JsonResponse, {___ "displayPosition" -> "{latitude" -> lat_,"longitude" -> long_ "}", "navigationPosition" -> "{{latitude" -> _Float, "longitude" -> _Float "}}", "mapView" -> "{bottomRight" -> "{latitude" -> _Float, "longitude" -> _Float "}", "topLeft" -> "{latitude" -> _Float, "longitude" -> _Float "}}", "locationId" -> _String, "locationType" -> "point", "address" -> "{city" -> _String, "label" -> _String, "country" -> _String, "county" -> county_, "state" -> state_, "street" -> st_, "houseNumber" -> num_, postalCode -> zip_ ___} -> {{lat, long} -> {st, num, zip, county, state}}, Infinity]

The code is a bit more complex, I extracted what may be useful to the problem. You won't match that pattern, I wrote it so you can get the point.

I need to make it consider the inner braces as part of the pattern to be matched (Mathematica parses them as meaning list, otherwise).

Here's my problem: I've got a JSON-formatted response and want to match some variables over the response. I'm doing it using Cases:

JsonResponse := Import["https://reverse.geocoder.api.here.com/6.2/reversegeocode.json?&app_code=djPZyynKsbTjIUDOBcHZ2g&app_id=xWVIueSv6JL0aJ5xqTxb&gen=3&int=true&jsonAttributes=1&languages=it-it&maxresults=9&mode=retrieveAddresses&prox=43.605979206920594,13.513478915691394,100", "JSON"]

Points = Cases[JsonResponse, {___ "displayPosition" -> "{latitude" -> lat_,"longitude" -> long_ "}", "navigationPosition" -> "{{latitude" -> _Float, "longitude" -> _Float "}}", "mapView" -> "{bottomRight" -> "{latitude" -> _Float, "longitude" -> _Float "}", "topLeft" -> "{latitude" -> _Float, "longitude" -> _Float "}}", "locationId" -> _String, "locationType" -> "point", "address" -> "{city" -> _String, "label" -> _String, "country" -> _String, "county" -> county_, "state" -> state_, "street" -> st_, "houseNumber" -> num_, postalCode -> zip_ ___} -> {{lat, long} -> {st, num, zip, county, state}}, Infinity]

I need to make it consider the inner braces as part of the pattern to be matched (Mathematica parses them as meaning list, otherwise).

added code
Source Link
JavierG
  • 541
  • 4
  • 10

Here's my problem: I've got a JSON-formatted response and want to match a variable distsome variables over the response. I'm doing it using Cases:

JsonResponse := Import["https://reverse.geocoder.api.here.com/6.2/reversegeocode.json?&app_code=djPZyynKsbTjIUDOBcHZ2g&app_id=xWVIueSv6JL0aJ5xqTxb&gen=3&int=true&jsonAttributes=1&languages=it-it&maxresults=9&mode=retrieveAddresses&prox=43.605979206920594,13.513478915691394,100", "JSON"]

DistancesPoints := Cases[JsonResponse, {___ "displayPosition" -> "{latitude" -> lat_,"longitude" -> long_ "}", "navigationPosition" -> "{"distance"{latitude" -> dist__Float, "longitude" -> _Float "}}", "mapView" -> "{bottomRight" -> "{latitude" -> _Float, "longitude" -> _Float "}", "topLeft" -> "{latitude" -> _Float, "longitude" -> _Float "}}", "locationId" -> _String, "locationType" -> "point", "address" -> "{city" -> _String, "label" -> _String, "country" -> _String, "county" -> county_, "state" -> state_, "street" -> st_, "houseNumber" -> num_, postalCode -> zip_ ___} -> dist{{lat, long} -> {st, num, zip, county, state}}, Infinity]

The code is a bit more complex, I extracted what may be useful to the problem. You won't match that pattern, I wrote it so you can get the point.

I need to make it consider the inner braces as part of the pattern to be matched (Mathematica parses them as meaning list, otherwise).

Here's my problem: I've got a JSON-formatted response and want to match a variable dist over the response. I'm doing it using Cases:

JsonResponse = Import["https://reverse.geocoder.api.here.com/6.2/reversegeocode.json?&app_code=djPZyynKsbTjIUDOBcHZ2g&app_id=xWVIueSv6JL0aJ5xqTxb&gen=3&int=true&jsonAttributes=1&languages=it-it&maxresults=9&mode=retrieveAddresses&prox=43.605979206920594,13.513478915691394,100", "JSON"]

Distances := Cases[JsonResponse, {___, {"distance" -> dist_}, ___} -> dist, Infinity]

The code is a bit more complex, I extracted what may be useful to the problem. You won't match that pattern, I wrote it so you can get the point.

I need to make it consider the inner braces as part of the pattern to be matched (Mathematica parses them as meaning list, otherwise).

Here's my problem: I've got a JSON-formatted response and want to match some variables over the response. I'm doing it using Cases:

JsonResponse := Import["https://reverse.geocoder.api.here.com/6.2/reversegeocode.json?&app_code=djPZyynKsbTjIUDOBcHZ2g&app_id=xWVIueSv6JL0aJ5xqTxb&gen=3&int=true&jsonAttributes=1&languages=it-it&maxresults=9&mode=retrieveAddresses&prox=43.605979206920594,13.513478915691394,100", "JSON"]

Points = Cases[JsonResponse, {___ "displayPosition" -> "{latitude" -> lat_,"longitude" -> long_ "}", "navigationPosition" -> "{{latitude" -> _Float, "longitude" -> _Float "}}", "mapView" -> "{bottomRight" -> "{latitude" -> _Float, "longitude" -> _Float "}", "topLeft" -> "{latitude" -> _Float, "longitude" -> _Float "}}", "locationId" -> _String, "locationType" -> "point", "address" -> "{city" -> _String, "label" -> _String, "country" -> _String, "county" -> county_, "state" -> state_, "street" -> st_, "houseNumber" -> num_, postalCode -> zip_ ___} -> {{lat, long} -> {st, num, zip, county, state}}, Infinity]

The code is a bit more complex, I extracted what may be useful to the problem. You won't match that pattern, I wrote it so you can get the point.

I need to make it consider the inner braces as part of the pattern to be matched (Mathematica parses them as meaning list, otherwise).

added 287 characters in body
Source Link
JavierG
  • 541
  • 4
  • 10

Here's my problem: I've got a JSON-formatted response and want to match a variable dist over the response. I'm doing it using Cases:

JsonResponse = Import["https://reverse.geocoder.api.here.com/6.2/reversegeocode.json?&app_code=djPZyynKsbTjIUDOBcHZ2g&app_id=xWVIueSv6JL0aJ5xqTxb&gen=3&int=true&jsonAttributes=1&languages=it-it&maxresults=9&mode=retrieveAddresses&prox=43.605979206920594,13.513478915691394,100", "JSON"]

Distances := Cases[JsonResponse, {___, {"distance" -> dist_}, ___} -> dist, Infinity]

The code is a bit more complex, I extracted what may be useful to the problem. You won't match that pattern, I wrote it so you can get the point.

I need to make it consider the inner braces as part of the pattern to be matched (Mathematica parses them as meaning list, otherwise).

Here's my problem: I've got a JSON-formatted response and want to match a variable dist over the response. I'm doing it using Cases:

Distances := Cases[JsonResponse, {___, {"distance" -> dist_}, ___} -> dist, Infinity]

I need to make it consider the inner braces as part of the pattern to be matched (Mathematica parses them as meaning list, otherwise).

Here's my problem: I've got a JSON-formatted response and want to match a variable dist over the response. I'm doing it using Cases:

JsonResponse = Import["https://reverse.geocoder.api.here.com/6.2/reversegeocode.json?&app_code=djPZyynKsbTjIUDOBcHZ2g&app_id=xWVIueSv6JL0aJ5xqTxb&gen=3&int=true&jsonAttributes=1&languages=it-it&maxresults=9&mode=retrieveAddresses&prox=43.605979206920594,13.513478915691394,100", "JSON"]

Distances := Cases[JsonResponse, {___, {"distance" -> dist_}, ___} -> dist, Infinity]

The code is a bit more complex, I extracted what may be useful to the problem. You won't match that pattern, I wrote it so you can get the point.

I need to make it consider the inner braces as part of the pattern to be matched (Mathematica parses them as meaning list, otherwise).

Formatted code
Source Link
MarcoB
  • 67.7k
  • 18
  • 96
  • 198
Loading
little typo
Source Link
JavierG
  • 541
  • 4
  • 10
Loading
Source Link
JavierG
  • 541
  • 4
  • 10
Loading