Hi hernan and others
I'm looking for ideas of simple services capital, dictionaries.... forecast that I could access using Zinc in a couple of lines. This is for challenges that I'm writing for the mooc. Stef |
Accessing the Nominatim service: http://wiki.openstreetmap.org/wiki/Nominatim .
http://ws.stfx.eu/ATBXE2DN83CW Best regards, Henrik -----Original Message----- From: Pharo-users [mailto:[hidden email]] On Behalf Of stepharo Sent: Sunday, March 13, 2016 9:52 PM To: Any question about pharo is welcome <[hidden email]> Subject: [Pharo-users] Ideas of web services that I could script in a couple of lines? Hi hernan and others I'm looking for ideas of simple services capital, dictionaries.... forecast that I could access using Zinc in a couple of lines. This is for challenges that I'm writing for the mooc. Stef |
In reply to this post by stepharo
I found
http://www.webservicex.net/globalweather.asmx/GetCitiesByCountry?CountryName=France Now I do not get why the output is so bad? It looks like they do say that the serve XML but this is not true ;( <?xml version="1.0" encoding="utf-8"?> <string xmlns="http://www.webserviceX.NET"><NewDataSet> <Table> <Country>France</Country> <City>Le Touquet</City> </Table> <Table> <Country>France</C (XMLDOMParser on: (ZnClient new url: 'http://www.webservicex.net/globalweather.asmx/GetCitiesByCountry?CountryName=France'; get)) parseDocument. (XMLDOMParser onURL: 'http://www.webservicex.net/globalweather.asmx/GetCitiesByCountry?CountryName=France') parseDocument Le 13/3/16 21:52, stepharo a écrit : > Hi hernan and others > > I'm looking for ideas of simple services > capital, dictionaries.... > forecast that I could access using Zinc in a couple of lines. > > This is for challenges that I'm writing for the mooc. > Stef > > > > |
In reply to this post by Henrik Nergaard
TX!!!!!!
Le 13/3/16 22:24, Henrik Nergaard a écrit : > Accessing the Nominatim service: http://wiki.openstreetmap.org/wiki/Nominatim . > > http://ws.stfx.eu/ATBXE2DN83CW > > Best regards, > Henrik > > -----Original Message----- > From: Pharo-users [mailto:[hidden email]] On Behalf Of stepharo > Sent: Sunday, March 13, 2016 9:52 PM > To: Any question about pharo is welcome <[hidden email]> > Subject: [Pharo-users] Ideas of web services that I could script in a couple of lines? > > Hi hernan and others > > I'm looking for ideas of simple services capital, dictionaries.... > forecast that I could access using Zinc in a couple of lines. > > This is for challenges that I'm writing for the mooc. > Stef > > > |
In reply to this post by Henrik Nergaard
Henrik
do you use MCFileTreeJsonParser just because this was just the JSON parser you got at hand? Stef Le 13/3/16 22:24, Henrik Nergaard a écrit : > Accessing the Nominatim service: http://wiki.openstreetmap.org/wiki/Nominatim . > > http://ws.stfx.eu/ATBXE2DN83CW > > Best regards, > Henrik > > -----Original Message----- > From: Pharo-users [mailto:[hidden email]] On Behalf Of stepharo > Sent: Sunday, March 13, 2016 9:52 PM > To: Any question about pharo is welcome <[hidden email]> > Subject: [Pharo-users] Ideas of web services that I could script in a couple of lines? > > Hi hernan and others > > I'm looking for ideas of simple services capital, dictionaries.... > forecast that I could access using Zinc in a couple of lines. > > This is for challenges that I'm writing for the mooc. > Stef > > > |
Correct, I used that for the example since it is by default in the Image .
Best regards, Henrik -----Original Message----- From: Pharo-users [mailto:[hidden email]] On Behalf Of stepharo Sent: Sunday, March 13, 2016 10:34 PM To: Any question about pharo is welcome <[hidden email]> Subject: Re: [Pharo-users] Ideas of web services that I could script in a couple of lines? Henrik do you use MCFileTreeJsonParser just because this was just the JSON parser you got at hand? Stef Le 13/3/16 22:24, Henrik Nergaard a écrit : > Accessing the Nominatim service: http://wiki.openstreetmap.org/wiki/Nominatim . > > http://ws.stfx.eu/ATBXE2DN83CW > > Best regards, > Henrik > > -----Original Message----- > From: Pharo-users [mailto:[hidden email]] On Behalf Of stepharo > Sent: Sunday, March 13, 2016 9:52 PM > To: Any question about pharo is welcome <[hidden email]> > Subject: [Pharo-users] Ideas of web services that I could script in a couple of lines? > > Hi hernan and others > > I'm looking for ideas of simple services capital, dictionaries.... > forecast that I could access using Zinc in a couple of lines. > > This is for challenges that I'm writing for the mooc. > Stef > > > |
> On 13 Mar 2016, at 22:42, Henrik Nergaard <[hidden email]> wrote: > > Correct, I used that for the example since it is by default in the Image . And that is a pity, IMHO, it sneaked in, while others have asked for NeoJSON to be included in the past ;-) Anyway, STON, which is also part of the base image can parse JSON just as well. STON fromString: '[42, {"JSON":true}, -1.5]'. You can also generate JSON. STON toJsonStringPretty: { 42. { 'JSON'->true } asDictionary. -1.5 }. STON toJsonString: { 42. { 'JSON'->true } asDictionary. -1.5 }. > Best regards, > Henrik > > -----Original Message----- > From: Pharo-users [mailto:[hidden email]] On Behalf Of stepharo > Sent: Sunday, March 13, 2016 10:34 PM > To: Any question about pharo is welcome <[hidden email]> > Subject: Re: [Pharo-users] Ideas of web services that I could script in a couple of lines? > > Henrik > > do you use MCFileTreeJsonParser > just because this was just the JSON parser you got at hand? > > Stef > > Le 13/3/16 22:24, Henrik Nergaard a écrit : >> Accessing the Nominatim service: http://wiki.openstreetmap.org/wiki/Nominatim . >> >> http://ws.stfx.eu/ATBXE2DN83CW >> >> Best regards, >> Henrik >> >> -----Original Message----- >> From: Pharo-users [mailto:[hidden email]] On Behalf Of stepharo >> Sent: Sunday, March 13, 2016 9:52 PM >> To: Any question about pharo is welcome <[hidden email]> >> Subject: [Pharo-users] Ideas of web services that I could script in a couple of lines? >> >> Hi hernan and others >> >> I'm looking for ideas of simple services capital, dictionaries.... >> forecast that I could access using Zinc in a couple of lines. >> >> This is for challenges that I'm writing for the mooc. >> Stef >> >> >> > > |
Ahh!
I was looking at STON first but could not find any #parseJsonString: or similar. Perhaps this should be mentioned in the class comment? :) Best regards, Henrik -----Original Message----- From: Pharo-users [mailto:[hidden email]] On Behalf Of Sven Van Caekenberghe Sent: Sunday, March 13, 2016 10:53 PM To: Any question about pharo is welcome <[hidden email]> Subject: Re: [Pharo-users] Ideas of web services that I could script in a couple of lines? > On 13 Mar 2016, at 22:42, Henrik Nergaard <[hidden email]> wrote: > > Correct, I used that for the example since it is by default in the Image . And that is a pity, IMHO, it sneaked in, while others have asked for NeoJSON to be included in the past ;-) Anyway, STON, which is also part of the base image can parse JSON just as well. STON fromString: '[42, {"JSON":true}, -1.5]'. You can also generate JSON. STON toJsonStringPretty: { 42. { 'JSON'->true } asDictionary. -1.5 }. STON toJsonString: { 42. { 'JSON'->true } asDictionary. -1.5 }. > Best regards, > Henrik > > -----Original Message----- > From: Pharo-users [mailto:[hidden email]] On Behalf Of stepharo > Sent: Sunday, March 13, 2016 10:34 PM > To: Any question about pharo is welcome <[hidden email]> > Subject: Re: [Pharo-users] Ideas of web services that I could script in a couple of lines? > > Henrik > > do you use MCFileTreeJsonParser > just because this was just the JSON parser you got at hand? > > Stef > > Le 13/3/16 22:24, Henrik Nergaard a écrit : >> Accessing the Nominatim service: http://wiki.openstreetmap.org/wiki/Nominatim . >> >> http://ws.stfx.eu/ATBXE2DN83CW >> >> Best regards, >> Henrik >> >> -----Original Message----- >> From: Pharo-users [mailto:[hidden email]] On Behalf Of stepharo >> Sent: Sunday, March 13, 2016 9:52 PM >> To: Any question about pharo is welcome <[hidden email]> >> Subject: [Pharo-users] Ideas of web services that I could script in a couple of lines? >> >> Hi hernan and others >> >> I'm looking for ideas of simple services capital, dictionaries.... >> forecast that I could access using Zinc in a couple of lines. >> >> This is for challenges that I'm writing for the mooc. >> Stef >> >> >> > > |
In reply to this post by stepharo
Hi Stef, Here are some examples: Get world capitals: ((NeoJSONReader fromString: ( ZnEasy get: 'http://api.geonames.org/countryInfoJSON' username: 'demo' password: '') contents) at: #geonames) collect: [ : d | d at: #capital ] Get poster of The Terminator movie: (ZnEasy getJpeg: ((NeoJSONReader fromString: (ZnClient new url: 'http://www.omdbapi.com/'; queryAt: 't' put: 'The Terminator'; get; contents)) at: #Poster)) inspect (ZnClient new url: 'http://worldcat.org/webservices/kb/rest/collections'; addPathSegment: 'search'; queryAt: 'q' put: 'Plato'; queryAt: 'wskey' put: '...'; get; contents)) inspect This is another wrapper for language detection (if you want to show a simple api wrapper) http://80738163270632.blogspot.com/2015/02/languagedetection-api-client-in.html Cheers, Hernán 2016-03-13 17:52 GMT-03:00 stepharo <[hidden email]>: Hi hernan and others |
In reply to this post by Sven Van Caekenberghe-2
>> On 13 Mar 2016, at 22:42, Henrik Nergaard <[hidden email]> wrote: >> >> Correct, I used that for the example since it is by default in the Image . > And that is a pity, IMHO, it sneaked in, while others have asked for NeoJSON to be included in the past ;-) Sven is STON able to replace MCFileTreeJsonParser if so can you open a bug entry and we kill it. You know my point of view of such parsers.... Stef > > Anyway, STON, which is also part of the base image can parse JSON just as well. > > STON fromString: '[42, {"JSON":true}, -1.5]'. > > You can also generate JSON. > > STON toJsonStringPretty: { 42. { 'JSON'->true } asDictionary. -1.5 }. > > STON toJsonString: { 42. { 'JSON'->true } asDictionary. -1.5 }. > >> Best regards, >> Henrik >> >> -----Original Message----- >> From: Pharo-users [mailto:[hidden email]] On Behalf Of stepharo >> Sent: Sunday, March 13, 2016 10:34 PM >> To: Any question about pharo is welcome <[hidden email]> >> Subject: Re: [Pharo-users] Ideas of web services that I could script in a couple of lines? >> >> Henrik >> >> do you use MCFileTreeJsonParser >> just because this was just the JSON parser you got at hand? >> >> Stef >> >> Le 13/3/16 22:24, Henrik Nergaard a écrit : >>> Accessing the Nominatim service: http://wiki.openstreetmap.org/wiki/Nominatim . >>> >>> http://ws.stfx.eu/ATBXE2DN83CW >>> >>> Best regards, >>> Henrik >>> >>> -----Original Message----- >>> From: Pharo-users [mailto:[hidden email]] On Behalf Of stepharo >>> Sent: Sunday, March 13, 2016 9:52 PM >>> To: Any question about pharo is welcome <[hidden email]> >>> Subject: [Pharo-users] Ideas of web services that I could script in a couple of lines? >>> >>> Hi hernan and others >>> >>> I'm looking for ideas of simple services capital, dictionaries.... >>> forecast that I could access using Zinc in a couple of lines. >>> >>> This is for challenges that I'm writing for the mooc. >>> Stef >>> >>> >>> >> > > |
In reply to this post by hernanmd
super!
Le 14/3/16 04:04, Hernán Morales Durand
a écrit :
|
In reply to this post by hernanmd
Hernán,
These are nice examples ! Sven > On 14 Mar 2016, at 04:04, Hernán Morales Durand <[hidden email]> wrote: > > Hi Stef, > > Here are some examples: > > Get world capitals: > > ((NeoJSONReader fromString: ( > ZnEasy > get: 'http://api.geonames.org/countryInfoJSON' > username: 'demo' > password: '') contents) at: #geonames) collect: [ : d | d at: #capital ] > > Get poster of The Terminator movie: > > (ZnEasy getJpeg: ((NeoJSONReader fromString: > (ZnClient new > url: 'http://www.omdbapi.com/'; > queryAt: 't' put: 'The Terminator'; > get; > contents)) at: #Poster)) inspect > > Another one to WorldCat but this needs an API key (I cannot test it now) > > (ZnClient new > url: 'http://worldcat.org/webservices/kb/rest/collections'; > addPathSegment: 'search'; > queryAt: 'q' put: 'Plato'; > queryAt: 'wskey' put: '...'; > get; > contents)) inspect > > This is another wrapper for language detection (if you want to show a simple api wrapper) > > http://80738163270632.blogspot.com/2015/02/languagedetection-api-client-in.html > > Cheers, > > Hernán > > > 2016-03-13 17:52 GMT-03:00 stepharo <[hidden email]>: > Hi hernan and others > > I'm looking for ideas of simple services > capital, dictionaries.... > forecast that I could access using Zinc in a couple of lines. > > This is for challenges that I'm writing for the mooc. > Stef > > > > |
This is because working with Pharo is becoming much easier every day :) Hernán2016-03-14 3:33 GMT-03:00 Sven Van Caekenberghe <[hidden email]>: Hernán, |
In reply to this post by Sven Van Caekenberghe-2
((STON fromString: (
ZnEasy get: 'http://api.geonames.org/countryInfoJSON' username: 'demo' password: '') contents) at: #geonames) collect: [ : d | d at: #capital ] With STON :) |
JSON is so pervasive that a base Pharo image should have things named after it. STON is supercool but there is no JSON name in it, that's an issue for me. What would be a good way to do that? I wonder. In the same vein, in Angular, consuming webservices that have a "proper" REST API (if there is such a thing, but still, this is nice) is easy with Restangular (https://github.com/mgonto/restangular). Not having such a thing has costed me much time during hackathons, during which competition using it was wrapping webservices at the speed of light while I was plodding along. Is there such a thing in Pharo? Phil On Mon, Mar 14, 2016 at 8:44 AM, stepharo <[hidden email]> wrote: ((STON fromString: ( |
> On 14 Mar 2016, at 09:33, [hidden email] wrote: > > JSON is so pervasive that a base Pharo image should have things named after it. > STON is supercool but there is no JSON name in it, that's an issue for me. > > What would be a good way to do that? I wonder. > > In the same vein, in Angular, consuming webservices that have a "proper" REST API (if there is such a thing, but still, this is nice) is easy with Restangular (https://github.com/mgonto/restangular). Not having such a thing has costed me much time during hackathons, during which competition using it was wrapping webservices at the speed of light while I was plodding along. > > Is there such a thing in Pharo? That would be a very nice project to do on top of Zn + NeoJSON ;-) > Phil > > On Mon, Mar 14, 2016 at 8:44 AM, stepharo <[hidden email]> wrote: > ((STON fromString: ( > ZnEasy > get: 'http://api.geonames.org/countryInfoJSON' > username: 'demo' > password: '') contents) at: #geonames) collect: [ : d | d at: #capital ] > > With STON :) > > > |
In reply to this post by stepharo
> On 14 Mar 2016, at 07:25, stepharo <[hidden email]> wrote: > > >>> On 13 Mar 2016, at 22:42, Henrik Nergaard <[hidden email]> wrote: >>> >>> Correct, I used that for the example since it is by default in the Image . >> And that is a pity, IMHO, it sneaked in, while others have asked for NeoJSON to be included in the past ;-) > > Sven is STON able to replace MCFileTreeJsonParser > if so can you open a bug entry and we kill it. You know my point of view of such parsers.... https://pharo.fogbugz.com/f/cases/17822/Use-STON-for-JSON-parsing-in-MC-FileTree > Stef >> >> Anyway, STON, which is also part of the base image can parse JSON just as well. >> >> STON fromString: '[42, {"JSON":true}, -1.5]'. >> >> You can also generate JSON. >> >> STON toJsonStringPretty: { 42. { 'JSON'->true } asDictionary. -1.5 }. >> >> STON toJsonString: { 42. { 'JSON'->true } asDictionary. -1.5 }. >> >>> Best regards, >>> Henrik >>> >>> -----Original Message----- >>> From: Pharo-users [mailto:[hidden email]] On Behalf Of stepharo >>> Sent: Sunday, March 13, 2016 10:34 PM >>> To: Any question about pharo is welcome <[hidden email]> >>> Subject: Re: [Pharo-users] Ideas of web services that I could script in a couple of lines? >>> >>> Henrik >>> >>> do you use MCFileTreeJsonParser >>> just because this was just the JSON parser you got at hand? >>> >>> Stef >>> >>> Le 13/3/16 22:24, Henrik Nergaard a écrit : >>>> Accessing the Nominatim service: http://wiki.openstreetmap.org/wiki/Nominatim . >>>> >>>> http://ws.stfx.eu/ATBXE2DN83CW >>>> >>>> Best regards, >>>> Henrik >>>> >>>> -----Original Message----- >>>> From: Pharo-users [mailto:[hidden email]] On Behalf Of stepharo >>>> Sent: Sunday, March 13, 2016 9:52 PM >>>> To: Any question about pharo is welcome <[hidden email]> >>>> Subject: [Pharo-users] Ideas of web services that I could script in a couple of lines? >>>> >>>> Hi hernan and others >>>> >>>> I'm looking for ideas of simple services capital, dictionaries.... >>>> forecast that I could access using Zinc in a couple of lines. >>>> >>>> This is for challenges that I'm writing for the mooc. >>>> Stef >>>> >>>> >>>> >>> >> >> > > |
In reply to this post by philippeback
> On 14 Mar 2016, at 09:33, [hidden email] wrote: > > JSON is so pervasive that a base Pharo image should have things named after it. > STON is supercool but there is no JSON name in it, that's an issue for me. I added a class facade STONJSON to make this more explicit (with tests): === Name: STON-Core-SvenVanCaekenberghe.70 Author: SvenVanCaekenberghe Time: 15 March 2016, 5:07:59.236863 pm UUID: c990d2ab-a407-4935-b489-c55139fdd665 Ancestors: STON-Core-SvenVanCaekenberghe.69 Improve class comments Add STONJSON facade class to make it more explicit that you can use STON for simple JSON parsing and generation Add STONJSONTests to test JSON compatibility === Name: STON-Tests-SvenVanCaekenberghe.62 Author: SvenVanCaekenberghe Time: 15 March 2016, 5:08:19.634401 pm UUID: 097090ae-a1ca-4401-86b0-07d7d446a9dc Ancestors: STON-Tests-SvenVanCaekenberghe.61 Improve class comments Add STONJSON facade class to make it more explicit that you can use STON for simple JSON parsing and generation Add STONJSONTests to test JSON compatibility === This is the STON class comment === STON implements serialization and materialization using the Smalltalk Object Notation format. I am a class side facade offering a high level API to write and read objects using STON. U s a g e Basic operations #toString: #fromString: STON toString: DisplayScreen boundingBox. STON fromString: 'Rectangle{#origin:Point[0,0],#corner:Point[1920,1030]}'. STON toString: { DateAndTime now. Float pi. 1 to: 10 by: 2. 3 days }. STON fromString: '[DateAndTime[''2016-03-15T13:57:59.462422+01:00''],3.141592653589793,Interval{#start:1,#stop:10,#step:2},Duration{#nanos:0,#seconds:259200}]' You can also read from or write to streams #fromStream: #put:onStream: There is also the option to do pretty printing (indenting, multi line output) #toStringPretty: #put:onStreamPretty: STON is more or less a superset of JSON and is backwards compatible with JSON while parsing, and can be compatible with it while writing. The important differences (and the whole reason why STON exists in the first place) are - class information (except for lists (Array) and maps (Dictionary)) - proper handling of shared and circular references - more Smalltalk like syntax (Symbols with #, single qouted Strings, nil instead of null) - more defined special types (Date, Time, DataAndTime, ByteArray, Point) Parsing JSON is done using #fromString: or #fromStream: with the results being composed of Arrays and Dictionaries. Writing objects as JSON is done using: #toJsonString[Pretty]: #put:asJsonOnStream[Pretty]: Note that you can only write Arrays and Dictionaries ! For a much more sophisticated JSON parser/writer implementation, have a look at NeoJSON. Like JSON, STON does not allow for comments. However, a preprocessor option can skip C style comments before parsing. I also define some contants used in the implementation: the class used as list, map and association, as well as the optional class name key (used when reading objects using an unknown class). I m p l e m e n t a t i o n The 2 key methods are #stonOn: #fromSton: which work together with STONWriter and STONReader; read their class comments for all configuration options (you can use the #reader and #writer methods to avoid referring to these classes directly). Several methods are used to support and/or control the implementation #stonName - defines the external name for a class #stonAllInstVarNames - defines which instance variable to write #stonContainSubObjects - shortcut looking into objects for subobjects #stonShouldWriteNilInstVars - option to skip writing nil valued instance variables S y n t a x value primitive-value object-value reference nil primitive-value number true false symbol string object-value object map list object classname map classname list reference @ int-index-previous-object-value map {} { members } members pair pair , members pair string : value symbol : value number : value list [] [ elements ] elements value value , elements string '' ' chars ' chars char char chars char any-printable-ASCII-character- except-'-"-or-\ \' \" \\ \/ \b \f \n \r \t \u four-hex-digits symbol # chars-limited # ' chars ' chars-limited char-limited char-limited chars-limited char-limited a-z A-Z 0-9 - _ . / classname uppercase-alpha-char alphanumeric-char number int int frac int exp int frac exp int digit digit1-9 digits - digit - digit1-9 digits frac . digits exp e digits digits digit digit digits e e e+ e- E E+ E- === And this is the STONJSON class comment === I am STONJSON, a class side facade to use STON as a simple JSON parser/writer. STON is more or less a superset of JSON and is backwards compatible with JSON while parsing, and can be compatible with it while writing. The important differences (and the whole reason why STON exists in the first place) are - class information (except for lists (Array) and maps (Dictionary)) - proper handling of shared and circular references - more Smalltalk like syntax (Symbols with #, single qouted Strings, nil instead of null) - more defined special types (Date, Time, DataAndTime, ByteArray, Point) Parsing JSON is done using #fromString: #fromStream: with the results being composed of Arrays and Dictionaries. Writing objects as JSON is done using #toString[Pretty]: #put:onStream[Pretty]: Note that you can only write Arrays and Dictionaries ! Shared and circular references will be noted and signalled using an exception. E x a m p l e s STONJSON toString: { 1. -1. Float pi. true. 'JSON' }. STONJSON fromString: '[1,-1,3.141592653589793,true,"JSON"]'. STONJSON toStringPretty: { #foo->1. #bar->2 } asDictionary. STONJSON fromString: '{"foo":1,"bar":2,"sub":{"a":true,"b":false},"flags":[1,8,32]}'. For a much more sophisticated JSON parser/writer implementation, have a look at NeoJSON. === > What would be a good way to do that? I wonder. Maybe we need some kind of central registry, maybe. Because the main goal would be to able to switch one implementation for another, but that would only work if their interfaces and behaviour match. Now, different implementations might share some API, but certainly will differ in other places, because they each offer different features. Sven |
In reply to this post by philippeback
Le 14/3/16 09:33, [hidden email] a
écrit :
Since STON can read and emit JSON I do not get the problem? Seaside REST Teapot
|
In reply to this post by Sven Van Caekenberghe-2
Wonderful. You are my hero :-) Phil On Tue, Mar 15, 2016 at 5:14 PM, Sven Van Caekenberghe <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |