[Pharo-users] NeoJSONParseError: invalid input: ' while parsing a Wikipedia exported article.

Offray Vladimir Luna Cárdenas offray.luna at mutabit.com
Sat Feb 8 22:56:01 EST 2020


Hi,

My hypothesis was closer to Erik's but I thought that being a JSON taken
from Wikimedia API, it should be correct. I didn't realize that I
converted it to STON to preserve line breaks and improve diff
friendliness. After using `STON fromString:` as advised by Peter,
everything worked well.

Thanks everyone for their timely "wisdom nuggets". I learned a little by
with each message here.

Cheers,

Offray

On 8/02/20 5:35 a. m., Sven Van Caekenberghe wrote:
> Hi,
>
> Like Erik says the input is indeed illegal JSON. JSON strings are delimited using double quotes not single quotes. There is no way around this, this is not optional.
>
> As Peter says, STON is more flexible. STON itself uses single quotes to be closer to Smalltalk. STON in its JSON compatibility mode does also recognise double quotes. So the class STONReader supports both, without further configuration.
>
> Sven
>
>> On 8 Feb 2020, at 10:34, PBKResearch <peter at pbkresearch.co.uk> wrote:
>>
>> Offray
>>
>> I have a workaround, not an explanation. I don't use NeoJSON, because for me the JSON facilities of STON are sufficient. So I tried you script with 'NeoJSONReader fromString:' replaced by 'STON fromString:' - everything worked perfectly, no parsing error. So clearly there is nothing wrong with your input file. If you have STON installed, or think it worth installing, this could get you moving.
>>
>> HTH
>>
>> Peter Kenny
>>
>> -----Original Message-----
>> From: Pharo-users <pharo-users-bounces at lists.pharo.org> On Behalf Of Offray Vladimir Luna Cárdenas
>> Sent: 08 February 2020 07:38
>> To: Any question about pharo is welcome <pharo-users at lists.pharo.org>
>> Subject: [Pharo-users] NeoJSONParseError: invalid input: ' while parsing a Wikipedia exported article.
>>
>> Hi,
>>
>> I'm trying to read the contents of a Wikipedia article that was exported from there using Wikipedias JSON API.
>>
>> The script I'm trying is:
>>
>> NeoJSONReader fromString:
>> 'https://mutabit.com/repos.fossil/pharopedia/doc/tip/docs/wikipedia.org/wiki/en/Pharo/contents.json'
>> asUrl retrieveContents utf8Decoded
>>
>> But I get "NeoJSONParseError: invalid input: '". As far as I can tell, the file at [1] seems like valid JSON, as is the one that Wikipedia API exports
>>
>> [1]
>> 'https://mutabit.com/repos.fossil/pharopedia/doc/tip/docs/wikipedia.org/wiki/en/Pharo/contents.json'
>>
>> Could anybody point me to a solution?
>>
>> Thanks,
>>
>> Offray
>>
>>
>>
>



More information about the Pharo-users mailing list