get json data from external url

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

get json data from external url

Sabine Manaa
I assume it is simple but I don't get it:

Entering this in the web browser, I get a Json string in the web browser:
http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false

I want to call this from Pharo and I want to use the results within pharo.

Can anyone give me a hint?

I was experimenting with sth like this but I was not successful:

(html jQuery getJson
       url: 'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false';
          onSuccess: '???';
                dataType: 'json') inspect

Regards
Sabine
Reply | Threaded
Open this post in threaded view
|

Re: get json data from external url

Sven Van Caekenberghe-2
Hi,

This will do (provided you have NeoJson loaded):

ZnClient new
  url: 'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false';
  contentReader: [ :entity | NeoJSONReader fromString: entity contents];
  get.

Sven

> On 15 Dec 2015, at 18:30, Sabine Manaa <[hidden email]> wrote:
>
> I assume it is simple but I don't get it:
>
> Entering this in the web browser, I get a Json string in the web browser:
> http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false
>
> I want to call this from Pharo and I want to use the results within pharo.
>
> Can anyone give me a hint?
>
> I was experimenting with sth like this but I was not successful:
>
> (html jQuery getJson
>       url:
> 'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false';
>         onSuccess: '???';
> dataType: 'json') inspect
>
> Regards
> Sabine
>
>
>
> --
> View this message in context: http://forum.world.st/get-json-data-from-external-url-tp4867166.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>


Reply | Threaded
Open this post in threaded view
|

Re: get json data from external url

Sabine Manaa
Hi Sven,

great and thanks a lot for the immediate response. I can proceed with this!

Have a nice christmas
Sabine

2015-12-15 18:47 GMT+01:00 Sven Van Caekenberghe-2 [via Smalltalk] <[hidden email]>:
Hi,

This will do (provided you have NeoJson loaded):

ZnClient new
  url: 'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false';
  contentReader: [ :entity | NeoJSONReader fromString: entity contents];
  get.

Sven

> On 15 Dec 2015, at 18:30, Sabine Manaa <[hidden email]> wrote:
>
> I assume it is simple but I don't get it:
>
> Entering this in the web browser, I get a Json string in the web browser:
> http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false
>
> I want to call this from Pharo and I want to use the results within pharo.
>
> Can anyone give me a hint?
>
> I was experimenting with sth like this but I was not successful:
>
> (html jQuery getJson
>       url:
> 'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false';
>         onSuccess: '???';
> dataType: 'json') inspect
>
> Regards
> Sabine
>
>
>
> --
> View this message in context: http://forum.world.st/get-json-data-from-external-url-tp4867166.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>





If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/get-json-data-from-external-url-tp4867166p4867169.html
To start a new topic under Pharo Smalltalk Users, email [hidden email]
To unsubscribe from get json data from external url, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: get json data from external url

Sabine Manaa
In reply to this post by Sabine Manaa
Hi Sven,

what do you recommend in this case:

ZnClient new
  url: 'http://maps.googleapis.com/maps/api/geocode/json?address=http://maps.googleapis.com/maps/api/geocode/json?address=Günsel Ideli, 8152 Glattbrugg, Schweiz&sensor=false&sensor=false';
  contentReader: [ :entity | NeoJSONReader fromString: entity contents];
ifFail: [:ex|  ];
  get.

->>
ZnCharacterEncodingError signal: 'ASCII character expected'

It is the "ü" n "Günsel" 

or:

ZnClient new 
  contentReader: [ :entity | NeoJSONReader fromString: entity contents]; 
ifFail: [:ex|  ];
  get.

"ã"

regards
Sabine

2015-12-15 19:23 GMT+01:00 Sabine Manaa <[hidden email]>:
Hi Sven,

great and thanks a lot for the immediate response. I can proceed with this!

Have a nice christmas
Sabine

2015-12-15 18:47 GMT+01:00 Sven Van Caekenberghe-2 [via Smalltalk] <[hidden email]>:
Hi,

This will do (provided you have NeoJson loaded):

ZnClient new
  url: 'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false';
  contentReader: [ :entity | NeoJSONReader fromString: entity contents];
  get.

Sven

> On 15 Dec 2015, at 18:30, Sabine Manaa <[hidden email]> wrote:
>
> I assume it is simple but I don't get it:
>
> Entering this in the web browser, I get a Json string in the web browser:
> http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false
>
> I want to call this from Pharo and I want to use the results within pharo.
>
> Can anyone give me a hint?
>
> I was experimenting with sth like this but I was not successful:
>
> (html jQuery getJson
>       url:
> 'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false';
>         onSuccess: '???';
> dataType: 'json') inspect
>
> Regards
> Sabine
>
>
>
> --
> View this message in context: http://forum.world.st/get-json-data-from-external-url-tp4867166.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>




If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/get-json-data-from-external-url-tp4867166p4867169.html
To start a new topic under Pharo Smalltalk Users, email [hidden email]
To unsubscribe from get json data from external url, click here.
NAML



View this message in context: Re: get json data from external url

Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: get json data from external url

Sven Van Caekenberghe-2
When putting non-ASCII in URLs it is best (needed) to construct the URL manually from components.

ZnClient new
  url: (ZnUrl new scheme: #http; host: 'maps.googleapis.com'; addPathSegments: #(maps api geocode json); queryAt: #address put: 'Flughafen Schönefeld, 12521 Schönefeld, Germany'; queryAt: #sensor put: false; yourself);
  contentReader: [ :entity | NeoJSONReader fromString: entity contents ];
  get.

If you know how to write such URL in their full encoded form, #asZnUrl still works.

'http://maps.googleapis.com/maps/api/geocode/json?address=Flughafen%20Sch%C3%B6nefeld,%2012521%20Sch%C3%B6nefeld,%20Germany&sensor=false' asZnUrl.

> On 15 Dec 2015, at 22:14, Sabine Manaa <[hidden email]> wrote:
>
> Hi Sven,
>
> what do you recommend in this case:
>
> ZnClient new
>   url: 'http://maps.googleapis.com/maps/api/geocode/json?address=http://maps.googleapis.com/maps/api/geocode/json?address=Günsel Ideli, 8152 Glattbrugg, Schweiz&sensor=false&sensor=false';
>   contentReader: [ :entity | NeoJSONReader fromString: entity contents];
> ifFail: [:ex|  ];
>   get.
>
> ->>
> ZnCharacterEncodingError signal: 'ASCII character expected'
>
> It is the "ü" n "Günsel"
>
> or:
>
> ZnClient new
>   url: 'http://maps.googleapis.com/maps/api/geocode/json?address=http://maps.googleapis.com/maps/api/geocode/json?address=Guarulhos - São Paulo, Brasilien&sensor=false&sensor=false';
>   contentReader: [ :entity | NeoJSONReader fromString: entity contents];
> ifFail: [:ex|  ];
>   get.
>
> "ã"
>
> regards
> Sabine
>
> 2015-12-15 19:23 GMT+01:00 Sabine Manaa <[hidden email]>:
> Hi Sven,
>
> great and thanks a lot for the immediate response. I can proceed with this!
>
> Have a nice christmas
> Sabine
>
> 2015-12-15 18:47 GMT+01:00 Sven Van Caekenberghe-2 [via Smalltalk] <[hidden email]>:
> Hi,
>
> This will do (provided you have NeoJson loaded):
>
> ZnClient new
>   url: 'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false';
>   contentReader: [ :entity | NeoJSONReader fromString: entity contents];
>   get.
>
> Sven
>
> > On 15 Dec 2015, at 18:30, Sabine Manaa <[hidden email]> wrote:
> >
> > I assume it is simple but I don't get it:
> >
> > Entering this in the web browser, I get a Json string in the web browser:
> > http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false
> >
> > I want to call this from Pharo and I want to use the results within pharo.
> >
> > Can anyone give me a hint?
> >
> > I was experimenting with sth like this but I was not successful:
> >
> > (html jQuery getJson
> >       url:
> > 'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false';
> >         onSuccess: '???';
> > dataType: 'json') inspect
> >
> > Regards
> > Sabine
> >
> >
> >
> > --
> > View this message in context: http://forum.world.st/get-json-data-from-external-url-tp4867166.html
> > Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
> >
>
>
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://forum.world.st/get-json-data-from-external-url-tp4867166p4867169.html
> To start a new topic under Pharo Smalltalk Users, email [hidden email]
> To unsubscribe from get json data from external url, click here.
> NAML
>
>
> View this message in context: Re: get json data from external url
>
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>


Reply | Threaded
Open this post in threaded view
|

Re: get json data from external url

Tudor Girba-2
Somewhat related: please keep in mind that the inspector provides basic support for navigating dictionaries, and this is equivalent with a JSON browser:


Cheers,
Doru



On Dec 15, 2015, at 11:44 PM, Sven Van Caekenberghe <[hidden email]> wrote:

When putting non-ASCII in URLs it is best (needed) to construct the URL manually from components.

ZnClient new 
 url: (ZnUrl new scheme: #http; host: 'maps.googleapis.com'; addPathSegments: #(maps api geocode json); queryAt: #address put: 'Flughafen Schönefeld, 12521 Schönefeld, Germany'; queryAt: #sensor put: false; yourself);
 contentReader: [ :entity | NeoJSONReader fromString: entity contents ]; 
 get.

If you know how to write such URL in their full encoded form, #asZnUrl still works.

'http://maps.googleapis.com/maps/api/geocode/json?address=Flughafen%20Sch%C3%B6nefeld,%2012521%20Sch%C3%B6nefeld,%20Germany&sensor=false' asZnUrl.

On 15 Dec 2015, at 22:14, Sabine Manaa <[hidden email]> wrote:

Hi Sven,

what do you recommend in this case:

ZnClient new 
 url: 'http://maps.googleapis.com/maps/api/geocode/json?address=http://maps.googleapis.com/maps/api/geocode/json?address=Günsel Ideli, 8152 Glattbrugg, Schweiz&sensor=false&sensor=false';
 contentReader: [ :entity | NeoJSONReader fromString: entity contents]; 
ifFail: [:ex|  ];
 get.

->>
ZnCharacterEncodingError signal: 'ASCII character expected'

It is the "ü" n "Günsel" 

or:

ZnClient new 
 url: 'http://maps.googleapis.com/maps/api/geocode/json?address=http://maps.googleapis.com/maps/api/geocode/json?address=Guarulhos - São Paulo, Brasilien&sensor=false&sensor=false';
 contentReader: [ :entity | NeoJSONReader fromString: entity contents]; 
ifFail: [:ex|  ];
 get.

"ã"

regards
Sabine

2015-12-15 19:23 GMT+01:00 Sabine Manaa <[hidden email]>:
Hi Sven,

great and thanks a lot for the immediate response. I can proceed with this!

Have a nice christmas
Sabine

2015-12-15 18:47 GMT+01:00 Sven Van Caekenberghe-2 [via Smalltalk] <[hidden email]>:
Hi, 

This will do (provided you have NeoJson loaded): 

ZnClient new 
 url: 'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false';
 contentReader: [ :entity | NeoJSONReader fromString: entity contents]; 
 get. 

Sven 

On 15 Dec 2015, at 18:30, Sabine Manaa <[hidden email]> wrote: 

I assume it is simple but I don't get it: 

Entering this in the web browser, I get a Json string in the web browser: 
http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false

I want to call this from Pharo and I want to use the results within pharo. 

Can anyone give me a hint? 

I was experimenting with sth like this but I was not successful: 

(html jQuery getJson 
     url: 
'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false';
       onSuccess: '???'; 
dataType: 'json') inspect 

Regards 
Sabine 



-- 
View this message in context: http://forum.world.st/get-json-data-from-external-url-tp4867166.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com. 





If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/get-json-data-from-external-url-tp4867166p4867169.html
To start a new topic under Pharo Smalltalk Users, email [hidden email] 
To unsubscribe from get json data from external url, click here.
NAML


View this message in context: Re: get json data from external url

Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.




--
www.tudorgirba.com
www.feenk.com

"Being happy is a matter of choice."




Reply | Threaded
Open this post in threaded view
|

Re: get json data from external url

Sabine Manaa
Hi Sven,

thanks, that works perfect and is much more readable.

Doru, yes the Inspector is very useful for that.

regards
Sabine

2015-12-16 6:25 GMT+01:00 Tudor Girba-2 [via Smalltalk] <[hidden email]>:
Somewhat related: please keep in mind that the inspector provides basic support for navigating dictionaries, and this is equivalent with a JSON browser:


Cheers,
Doru



On Dec 15, 2015, at 11:44 PM, Sven Van Caekenberghe <[hidden email]> wrote:

When putting non-ASCII in URLs it is best (needed) to construct the URL manually from components.

ZnClient new 
 url: (ZnUrl new scheme: #http; host: 'maps.googleapis.com'; addPathSegments: #(maps api geocode json); queryAt: #address put: 'Flughafen Schönefeld, 12521 Schönefeld, Germany'; queryAt: #sensor put: false; yourself);
 contentReader: [ :entity | NeoJSONReader fromString: entity contents ]; 
 get.

If you know how to write such URL in their full encoded form, #asZnUrl still works.

'http://maps.googleapis.com/maps/api/geocode/json?address=Flughafen%20Sch%C3%B6nefeld,%2012521%20Sch%C3%B6nefeld,%20Germany&sensor=false' asZnUrl.

On 15 Dec 2015, at 22:14, Sabine Manaa <[hidden email]> wrote:

Hi Sven,

what do you recommend in this case:

ZnClient new 
 url: 'http://maps.googleapis.com/maps/api/geocode/json?address=http://maps.googleapis.com/maps/api/geocode/json?address=Günsel Ideli, 8152 Glattbrugg, Schweiz&sensor=false&sensor=false';
 contentReader: [ :entity | NeoJSONReader fromString: entity contents]; 
ifFail: [:ex|  ];
 get.

->>
ZnCharacterEncodingError signal: 'ASCII character expected'

It is the "ü" n "Günsel" 

or:

ZnClient new 
 url: 'http://maps.googleapis.com/maps/api/geocode/json?address=http://maps.googleapis.com/maps/api/geocode/json?address=Guarulhos - São Paulo, Brasilien&sensor=false&sensor=false';
 contentReader: [ :entity | NeoJSONReader fromString: entity contents]; 
ifFail: [:ex|  ];
 get.

"ã"

regards
Sabine

2015-12-15 19:23 GMT+01:00 Sabine Manaa <[hidden email]>:
Hi Sven,

great and thanks a lot for the immediate response. I can proceed with this!

Have a nice christmas
Sabine

2015-12-15 18:47 GMT+01:00 Sven Van Caekenberghe-2 [via Smalltalk] <[hidden email]>:
Hi, 

This will do (provided you have NeoJson loaded): 

ZnClient new 
 url: 'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false';
 contentReader: [ :entity | NeoJSONReader fromString: entity contents]; 
 get. 

Sven 

On 15 Dec 2015, at 18:30, Sabine Manaa <[hidden email]> wrote: 

I assume it is simple but I don't get it: 

Entering this in the web browser, I get a Json string in the web browser: 
http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false

I want to call this from Pharo and I want to use the results within pharo. 

Can anyone give me a hint? 

I was experimenting with sth like this but I was not successful: 

(html jQuery getJson 
     url: 
'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false';
       onSuccess: '???'; 
dataType: 'json') inspect 

Regards 
Sabine 



-- 
View this message in context: http://forum.world.st/get-json-data-from-external-url-tp4867166.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com. 





If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/get-json-data-from-external-url-tp4867166p4867169.html
To start a new topic under Pharo Smalltalk Users, email [hidden email] 
To unsubscribe from get json data from external url, click here.
NAML


View this message in context: Re: get json data from external url

Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.




--
www.tudorgirba.com
www.feenk.com

"Being happy is a matter of choice."







If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/get-json-data-from-external-url-tp4867166p4867243.html
To start a new topic under Pharo Smalltalk Users, email [hidden email]
To unsubscribe from get json data from external url, click here.
NAML