New Pharo user, some questions

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

Re: New Pharo user, some questions

dboeren
Thanks for spotting that Hernán, I'm not sure how that managed to pass unnoticed so long :)

On Thu, Dec 11, 2014 at 11:04 AM, Hernán Morales Durand <[hidden email]> wrote:
2014-12-10 17:26 GMT-03:00 dboeren <[hidden email]>:
\u009e

You have a typo there. It should be

\u00e9

#copyReplaceAll:with: is working without problems.

Cheers,

Hernán


2014-12-11 10:45 GMT-03:00 David Boeren <[hidden email]>:
I could, but if I do it before parsing, I only have to do the string replacement in one place.  If I do it afterward, I have to apply it to every field separately which I think makes the code look messier.  Anyway, I have tried applying it at the individual field level as a test but it didn't work there either.  My primary concern at this point is just to get it working which has nothing to do with JSON at all, this is purely a string operation.


On Thu, Dec 11, 2014 at 1:37 AM, Sven Van Caekenberghe <[hidden email]> wrote:

> On 11 Dec 2014, at 04:41, David Boeren <[hidden email]> wrote:
>
> That's the next line of code after what I quoted:
>
>       "Parse the JSON data returned by the api"
>       data := NeoJSONReader fromString: response.
>
> But, prior to the JSON parsing I was doing a couple of string replacements to patch up the data.  The system I'm moving the data into doesn't accept accented characters or bullets, and it wants empty strings instead of nulls.

You can do the replacements after parsing too, just manipulating the generated data structures. I would say that is conceptually more correct.

> All the JSON stuff works fine.  It's just the string operations with copyReplaceAll:with: that aren't working as expected for some reason.
>
> Or are you saying that the data I get from from asUrl retrieveContents is not a "proper string" and maybe that's why it's not working?
>
>
> On Wed, Dec 10, 2014 at 6:34 PM, Sven Van Caekenberghe <[hidden email]> wrote:
>
> > On 10 Dec 2014, at 21:26, dboeren <[hidden email]> wrote:
> >
> >       "Fetch the raw JSON data from dtdb.co"
> >       response := 'http://dtdb.co/api/cards/' asUrl retrieveContents asString.
>
> Why no do
>
> NeoJSONReader fromString: 'http://dtdb.co/api/cards/' asUrl retrieveContents
>
> ?
>
> You'll get the data back, nicely parsed and converted to proper Pharo strings.
>
> Sven
>




12