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
Accessing the Nominatim service: http://wiki.openstreetmap.org/wiki/Nominatim . http://ws.stfx.eu/ATBXE2DN83CW Best regards, Henrik -----Original Message----- From: Pharo-users [mailto:pharo-users-bounces@lists.pharo.org] On Behalf Of stepharo Sent: Sunday, March 13, 2016 9:52 PM To: Any question about pharo is welcome <pharo-users@lists.pharo.org> 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
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:pharo-users-bounces@lists.pharo.org] On Behalf Of stepharo Sent: Sunday, March 13, 2016 9:52 PM To: Any question about pharo is welcome <pharo-users@lists.pharo.org> 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
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:pharo-users-bounces@lists.pharo.org] On Behalf Of stepharo Sent: Sunday, March 13, 2016 9:52 PM To: Any question about pharo is welcome <pharo-users@lists.pharo.org> 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:pharo-users-bounces@lists.pharo.org] On Behalf Of stepharo Sent: Sunday, March 13, 2016 10:34 PM To: Any question about pharo is welcome <pharo-users@lists.pharo.org> 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:pharo-users-bounces@lists.pharo.org] On Behalf Of stepharo Sent: Sunday, March 13, 2016 9:52 PM To: Any question about pharo is welcome <pharo-users@lists.pharo.org> 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 <henrik.nergaard@uia.no> 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:pharo-users-bounces@lists.pharo.org] On Behalf Of stepharo Sent: Sunday, March 13, 2016 10:34 PM To: Any question about pharo is welcome <pharo-users@lists.pharo.org> 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:pharo-users-bounces@lists.pharo.org] On Behalf Of stepharo Sent: Sunday, March 13, 2016 9:52 PM To: Any question about pharo is welcome <pharo-users@lists.pharo.org> 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:pharo-users-bounces@lists.pharo.org] On Behalf Of Sven Van Caekenberghe Sent: Sunday, March 13, 2016 10:53 PM To: Any question about pharo is welcome <pharo-users@lists.pharo.org> 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 <henrik.nergaard@uia.no> 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:pharo-users-bounces@lists.pharo.org] On Behalf Of stepharo Sent: Sunday, March 13, 2016 10:34 PM To: Any question about pharo is welcome <pharo-users@lists.pharo.org> 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:pharo-users-bounces@lists.pharo.org] On Behalf Of stepharo Sent: Sunday, March 13, 2016 9:52 PM To: Any question about pharo is welcome <pharo-users@lists.pharo.org> 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 <henrik.nergaard@uia.no> 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:pharo-users-bounces@lists.pharo.org] On Behalf Of stepharo Sent: Sunday, March 13, 2016 10:34 PM To: Any question about pharo is welcome <pharo-users@lists.pharo.org> 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:pharo-users-bounces@lists.pharo.org] On Behalf Of stepharo Sent: Sunday, March 13, 2016 9:52 PM To: Any question about pharo is welcome <pharo-users@lists.pharo.org> 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 14 Mar 2016, at 07:25, stepharo <stepharo@free.fr> wrote:
On 13 Mar 2016, at 22:42, Henrik Nergaard <henrik.nergaard@uia.no> 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-File...
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:pharo-users-bounces@lists.pharo.org] On Behalf Of stepharo Sent: Sunday, March 13, 2016 10:34 PM To: Any question about pharo is welcome <pharo-users@lists.pharo.org> 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:pharo-users-bounces@lists.pharo.org] On Behalf Of stepharo Sent: Sunday, March 13, 2016 9:52 PM To: Any question about pharo is welcome <pharo-users@lists.pharo.org> 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
Pretty nice! I'm taking note of such small gems in an interactive [grafoscopio](http://smalltalkhub.com/#!/~Offray/Grafoscopio/) notebook. When they take the form of such notebooks I don't know how they should be credited... any suggestions? Cheers, Offray On 13/03/16 16:24, Henrik Nergaard wrote:
Accessing the Nominatim service: http://wiki.openstreetmap.org/wiki/Nominatim .
http://ws.stfx.eu/ATBXE2DN83CW
Best regards, Henrik
-----Original Message----- From: Pharo-users [mailto:pharo-users-bounces@lists.pharo.org] On Behalf Of stepharo Sent: Sunday, March 13, 2016 9:52 PM To: Any question about pharo is welcome <pharo-users@lists.pharo.org> 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
I found http://www.webservicex.net/globalweather.asmx/GetCitiesByCountry?CountryName... 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...'; get)) parseDocument. (XMLDOMParser onURL: 'http://www.webservicex.net/globalweather.asmx/GetCitiesByCountry?CountryName...') 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
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.h... Cheers, Hernán 2016-03-13 17:52 GMT-03:00 stepharo <stepharo@free.fr>:
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
super! Le 14/3/16 04:04, Hernán Morales Durand a écrit :
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.h...
Cheers,
Hernán
2016-03-13 17:52 GMT-03:00 stepharo <stepharo@free.fr <mailto:stepharo@free.fr>>:
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
Hernán, These are nice examples ! Sven
On 14 Mar 2016, at 04:04, Hernán Morales Durand <hernan.morales@gmail.com> 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.h...
Cheers,
Hernán
2016-03-13 17:52 GMT-03:00 stepharo <stepharo@free.fr>: 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án 2016-03-14 3:33 GMT-03:00 Sven Van Caekenberghe <sven@stfx.eu>:
Hernán,
These are nice examples !
Sven
On 14 Mar 2016, at 04:04, Hernán Morales Durand < hernan.morales@gmail.com> 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.h...
Cheers,
Hernán
2016-03-13 17:52 GMT-03:00 stepharo <stepharo@free.fr>: 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
((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 <stepharo@free.fr> wrote:
((STON fromString: ( ZnEasy get: 'http://api.geonames.org/countryInfoJSON' username: 'demo' password: '') contents) at: #geonames) collect: [ : d | d at: #capital ]
With STON :)
On 14 Mar 2016, at 09:33, phil@highoctane.be 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 <stepharo@free.fr> wrote: ((STON fromString: ( ZnEasy get: 'http://api.geonames.org/countryInfoJSON' username: 'demo' password: '') contents) at: #geonames) collect: [ : d | d at: #capital ]
With STON :)
On 14 Mar 2016, at 09:33, phil@highoctane.be 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
Wonderful. You are my hero :-) Phil On Tue, Mar 15, 2016 at 5:14 PM, Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 14 Mar 2016, at 09:33, phil@highoctane.be 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
Le 14/3/16 09:33, phil@highoctane.be a écrit :
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.
Since STON can read and emit JSON I do not get the problem?
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?
Seaside REST Teapot
Phil
On Mon, Mar 14, 2016 at 8:44 AM, stepharo <stepharo@free.fr <mailto:stepharo@free.fr>> wrote:
((STON fromString: ( ZnEasy get: 'http://api.geonames.org/countryInfoJSON' username: 'demo' password: '') contents) at: #geonames) collect: [ : d | d at: #capital ]
With STON :)
On Tue, Mar 15, 2016 at 6:08 PM, stepharo <stepharo@free.fr> wrote:
Le 14/3/16 09:33, phil@highoctane.be a écrit :
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.
Since STON can read and emit JSON I do not get the problem?
Discoverability. See Sven other mail.
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> 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?
Seaside REST
No: this is for exposing endpoints, not consuming them. See Restangular.
Teapot
No: same. I use SeasideREST and Teapot BTW.
Phil
On Mon, Mar 14, 2016 at 8:44 AM, stepharo <stepharo@free.fr> wrote:
((STON fromString: ( ZnEasy get: 'http://api.geonames.org/countryInfoJSON' username: 'demo' password: '') contents) at: #geonames) collect: [ : d | d at: #capital ]
With STON :)
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?
Seaside REST
No: this is for exposing endpoints, not consuming them. See Restangular.
I know you are busy but me too. So what do you mean consuming them?
Teapot
No: same.
I use SeasideREST and Teapot BTW.
Phil
On Mon, Mar 14, 2016 at 8:44 AM, stepharo <stepharo@free.fr <mailto:stepharo@free.fr>> wrote:
((STON fromString: ( ZnEasy get: 'http://api.geonames.org/countryInfoJSON' username: 'demo' password: '') contents) at: #geonames) collect: [ : d | d at: #capital ]
With STON :)
Phil is simply pointing out that if someone will look for JSON, the first thing that person will try will be to type âJSONâ in Spotter and expect to find something for it. So, now there is a class called STONJSON. Cheers, Doru
On Mar 16, 2016, at 5:48 PM, stepharo <stepharo@free.fr> wrote:
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?
Seaside REST
No: this is for exposing endpoints, not consuming them. See Restangular.
I know you are busy but me too. So what do you mean consuming them?
Teapot
No: same.
I use SeasideREST and Teapot BTW.
Phil
On Mon, Mar 14, 2016 at 8:44 AM, stepharo <stepharo@free.fr> wrote: ((STON fromString: ( ZnEasy get: 'http://api.geonames.org/countryInfoJSON' username: 'demo' password: '') contents) at: #geonames) collect: [ : d | d at: #capital ]
With STON :)
-- www.tudorgirba.com www.feenk.com "There are no old things, there are only old ways of looking at them."
Hi, The last version of the tutorial grafoscopio notebook now includes these cool examples (credit is done with a Thanks line). Here is a cool preview ;-): You can get this interactive documentation by installing grafoscopio [1] and then choosing from the docking bar "Actualizar > Documentación > Tutorial" (Sorry, for now interface and documentation are only in Spanish) [1] http://smalltalkhub.com/#!/~Offray/Grafoscopio/ Thanks for these great examples, they're a nice addition to the interactive documentation. Cheers, Offray On 14/03/16 01:33, Sven Van Caekenberghe wrote:
(ZnEasy getJpeg: ((NeoJSONReader fromString:
(ZnClient new url: 'http://www.omdbapi.com/'; queryAt: 't' put: 'The Terminator'; get; contents)) at: #Poster)) inspect
Looks cool. I wonder if this would make a good basis for the main Image help system? cheers -ben On Wed, Mar 16, 2016 at 10:15 AM, Offray Vladimir Luna Cárdenas < offray.luna@mutabit.com> wrote:
Hi,
The last version of the tutorial grafoscopio notebook now includes these cool examples (credit is done with a Thanks line). Here is a cool preview ;-):
You can get this interactive documentation by installing grafoscopio [1] and then choosing from the docking bar "Actualizar > Documentación > Tutorial" (Sorry, for now interface and documentation are only in Spanish)
[1] http://smalltalkhub.com/#!/~Offray/Grafoscopio/
Thanks for these great examples, they're a nice addition to the interactive documentation.
Cheers,
Offray
On 14/03/16 01:33, Sven Van Caekenberghe wrote:
(ZnEasy getJpeg: ((NeoJSONReader fromString: > (ZnClient new> url: 'http://www.omdbapi.com/';> queryAt: 't' put: 'The Terminator';> get;> contents)) at: #Poster)) inspect
wait I'm putting them as challenge for the mooc Do not spoil the fun of students :) Le 16/3/16 06:00, Ben Coman a écrit :
Looks cool. I wonder if this would make a good basis for the main Image help system? cheers -ben
On Wed, Mar 16, 2016 at 10:15 AM, Offray Vladimir Luna Cárdenas <offray.luna@mutabit.com <mailto:offray.luna@mutabit.com>> wrote:
Hi,
The last version of the tutorial grafoscopio notebook now includes these cool examples (credit is done with a Thanks line). Here is a cool preview ;-):
You can get this interactive documentation by installing grafoscopio [1] and then choosing from the docking bar "Actualizar > Documentación > Tutorial" (Sorry, for now interface and documentation are only in Spanish)
[1] http://smalltalkhub.com/#!/~Offray/Grafoscopio/ <http://smalltalkhub.com/#%21/%7EOffray/Grafoscopio/>
Thanks for these great examples, they're a nice addition to the interactive documentation.
Cheers,
Offray
On 14/03/16 01:33, Sven Van Caekenberghe wrote:
(ZnEasy getJpeg: ((NeoJSONReader fromString: > (ZnClient new > url: 'http://www.omdbapi.com/'; > queryAt: 't' put: 'The Terminator'; > get; > contents)) at: #Poster)) inspect
That would certainly close the circle, because I used Help System source code as an inspiration on how tree-like documentation could be implemented inside the image, but adding more interactivity and flexibility. In the attachment you can see the piece where I talk about this and full text is in [1]. [1] http://mutabit.com/repos.fossil/grafoscopio/doc/tip/Docs/Es/Articulos/Libert... Pharo allows me to explore old ideas [2] about exploratory computing, interactive documents and writing [2] http://mutabit.com/offray/static/blog/output/posts/on-deepness-and-complexit... Thanks for that :-), Offray On 16/03/16 00:00, Ben Coman wrote:
Looks cool. I wonder if this would make a good basis for the main Image help system? cheers -ben
On Wed, Mar 16, 2016 at 10:15 AM, Offray Vladimir Luna Cárdenas <offray.luna@mutabit.com <mailto:offray.luna@mutabit.com>> wrote:
Hi,
The last version of the tutorial grafoscopio notebook now includes these cool examples (credit is done with a Thanks line). Here is a cool preview ;-):
You can get this interactive documentation by installing grafoscopio [1] and then choosing from the docking bar "Actualizar > Documentación > Tutorial" (Sorry, for now interface and documentation are only in Spanish)
[1] http://smalltalkhub.com/#!/~Offray/Grafoscopio/ <http://smalltalkhub.com/#%21/%7EOffray/Grafoscopio/>
Thanks for these great examples, they're a nice addition to the interactive documentation.
Cheers,
Offray
On 14/03/16 01:33, Sven Van Caekenberghe wrote:
(ZnEasy getJpeg: ((NeoJSONReader fromString: > (ZnClient new > url: 'http://www.omdbapi.com/'; > queryAt: 't' put: 'The Terminator'; > get; > contents)) at: #Poster)) inspect
participants (8)
-
Ben Coman -
Henrik Nergaard -
Hernán Morales Durand -
Offray Vladimir Luna Cárdenas -
phil@highoctane.be -
stepharo -
Sven Van Caekenberghe -
Tudor Girba