pharo-users@lists.pharo.org

Any question about pharo is welcome

View all threads

Problem with Dictionary and Associations

D
David@totallyobjects.com
Wed, Feb 10, 2021 6:18 PM

I am using STON to objects out to disk. Up to two days ago, I was reading them in as Dictionaries and converting to objects from there. All of a sudden yesterday morning, I got an error saying that the association is only indexable with integers. Even so, I don't seem to be able to access the contents.

Fistly, any ideas why this has changed and secondly, any ideas how to fix it?

David
Totally Objects

Sent from my Huawei tablet

I am using STON to objects out to disk. Up to two days ago, I was reading them in as Dictionaries and converting to objects from there. All of a sudden yesterday morning, I got an error saying that the association is only indexable with integers. Even so, I don't seem to be able to access the contents. Fistly, any ideas why this has changed and secondly, any ideas how to fix it? David Totally Objects Sent from my Huawei tablet
SV
Sven Van Caekenberghe
Wed, Feb 10, 2021 7:17 PM

Hi David,

On 10 Feb 2021, at 19:18, David@totallyobjects.com wrote:

I am using STON to objects out to disk. Up to two days ago, I was reading them in as Dictionaries and converting to objects from there. All of a sudden yesterday morning, I got an error saying that the association is only indexable with integers. Even so, I don't seem to be able to access the contents.

Fistly, any ideas why this has changed and secondly, any ideas how to fix it?

David
Totally Objects

Sent from my Huawei tablet

I am afraid I need more information.

Could you create a reproducible case ?
Do you have a stack trace ?

In any case, STON is a text format, that can be edited (in most cases, shared or circular references being hard to edit by hand).

Sven

Hi David, > On 10 Feb 2021, at 19:18, David@totallyobjects.com wrote: > > I am using STON to objects out to disk. Up to two days ago, I was reading them in as Dictionaries and converting to objects from there. All of a sudden yesterday morning, I got an error saying that the association is only indexable with integers. Even so, I don't seem to be able to access the contents. > > Fistly, any ideas why this has changed and secondly, any ideas how to fix it? > > David > Totally Objects > > Sent from my Huawei tablet I am afraid I need more information. Could you create a reproducible case ? Do you have a stack trace ? In any case, STON is a text format, that can be edited (in most cases, shared or circular references being hard to edit by hand). Sven
DP
David Pennington
Thu, Feb 11, 2021 3:33 PM

I attach a couple of screen shots and a file containing the item that I am trying to open. What else can I supply? This has been working for a couple of weeks and suddenly doesn’t work. I save the JSON and then load it back again. I enclose a file with the JSON as contents. As you can see from the screenshot, the debugger shows it as a dictionary but the execution path takes it to an Association which is what I don’t understand.

On 10 Feb 2021, at 19:17, Sven Van Caekenberghe sven@stfx.eu wrote:

Hi David,

On 10 Feb 2021, at 19:18, David@totallyobjects.com wrote:

I am using STON to objects out to disk. Up to two days ago, I was reading them in as Dictionaries and converting to objects from there. All of a sudden yesterday morning, I got an error saying that the association is only indexable with integers. Even so, I don't seem to be able to access the contents.

Fistly, any ideas why this has changed and secondly, any ideas how to fix it?

David
Totally Objects

Sent from my Huawei tablet

I am afraid I need more information.

Could you create a reproducible case ?
Do you have a stack trace ?

In any case, STON is a text format, that can be edited (in most cases, shared or circular references being hard to edit by hand).

Sven

I attach a couple of screen shots and a file containing the item that I am trying to open. What else can I supply? This has been working for a couple of weeks and suddenly doesn’t work. I save the JSON and then load it back again. I enclose a file with the JSON as contents. As you can see from the screenshot, the debugger shows it as a dictionary but the execution path takes it to an Association which is what I don’t understand. > On 10 Feb 2021, at 19:17, Sven Van Caekenberghe <sven@stfx.eu> wrote: > > Hi David, > >> On 10 Feb 2021, at 19:18, David@totallyobjects.com wrote: >> >> I am using STON to objects out to disk. Up to two days ago, I was reading them in as Dictionaries and converting to objects from there. All of a sudden yesterday morning, I got an error saying that the association is only indexable with integers. Even so, I don't seem to be able to access the contents. >> >> Fistly, any ideas why this has changed and secondly, any ideas how to fix it? >> >> David >> Totally Objects >> >> Sent from my Huawei tablet > > I am afraid I need more information. > > Could you create a reproducible case ? > Do you have a stack trace ? > > In any case, STON is a text format, that can be edited (in most cases, shared or circular references being hard to edit by hand). > > Sven
H
hogoww
Thu, Feb 11, 2021 3:36 PM

Are you on Pharo 8?
I think I encountered this bug not so long ago.
From your screenshot, it look like it
https://github.com/pharo-project/pharo/issues/8411?

Pierre

On 11/02/2021 16:33, David Pennington wrote:

I attach a couple of screen shots and a file containing the item that I am trying to open. What else can I supply? This has been working for a couple of weeks and suddenly doesn’t work. I save the JSON and then load it back again. I enclose a file with the JSON as contents. As you can see from the screenshot, the debugger shows it as a dictionary but the execution path takes it to an Association which is what I don’t understand.

On 10 Feb 2021, at 19:17, Sven Van Caekenberghe sven@stfx.eu wrote:

Hi David,

On 10 Feb 2021, at 19:18, David@totallyobjects.com wrote:

I am using STON to objects out to disk. Up to two days ago, I was reading them in as Dictionaries and converting to objects from there. All of a sudden yesterday morning, I got an error saying that the association is only indexable with integers. Even so, I don't seem to be able to access the contents.

Fistly, any ideas why this has changed and secondly, any ideas how to fix it?

David
Totally Objects

Sent from my Huawei tablet

I am afraid I need more information.

Could you create a reproducible case ?
Do you have a stack trace ?

In any case, STON is a text format, that can be edited (in most cases, shared or circular references being hard to edit by hand).

Sven

Are you on Pharo 8? I think I encountered this bug not so long ago. From your screenshot, it look like it https://github.com/pharo-project/pharo/issues/8411? Pierre On 11/02/2021 16:33, David Pennington wrote: > I attach a couple of screen shots and a file containing the item that I am trying to open. What else can I supply? This has been working for a couple of weeks and suddenly doesn’t work. I save the JSON and then load it back again. I enclose a file with the JSON as contents. As you can see from the screenshot, the debugger shows it as a dictionary but the execution path takes it to an Association which is what I don’t understand. > > > >> On 10 Feb 2021, at 19:17, Sven Van Caekenberghe <sven@stfx.eu> wrote: >> >> Hi David, >> >>> On 10 Feb 2021, at 19:18, David@totallyobjects.com wrote: >>> >>> I am using STON to objects out to disk. Up to two days ago, I was reading them in as Dictionaries and converting to objects from there. All of a sudden yesterday morning, I got an error saying that the association is only indexable with integers. Even so, I don't seem to be able to access the contents. >>> >>> Fistly, any ideas why this has changed and secondly, any ideas how to fix it? >>> >>> David >>> Totally Objects >>> >>> Sent from my Huawei tablet >> I am afraid I need more information. >> >> Could you create a reproducible case ? >> Do you have a stack trace ? >> >> In any case, STON is a text format, that can be edited (in most cases, shared or circular references being hard to edit by hand). >> >> Sven
DP
David Pennington
Thu, Feb 11, 2021 3:58 PM

Yes but I can’t see any resolution on GitHub

On 11 Feb 2021, at 15:36, hogoww pierre.misse-chanabier@inria.fr wrote:

Are you on Pharo 8?
I think I encountered this bug not so long ago.
From your screenshot, it look like it https://github.com/pharo-project/pharo/issues/8411 https://github.com/pharo-project/pharo/issues/8411?

Pierre

On 11/02/2021 16:33, David Pennington wrote:

I attach a couple of screen shots and a file containing the item that I am trying to open. What else can I supply? This has been working for a couple of weeks and suddenly doesn’t work. I save the JSON and then load it back again. I enclose a file with the JSON as contents. As you can see from the screenshot, the debugger shows it as a dictionary but the execution path takes it to an Association which is what I don’t understand.

On 10 Feb 2021, at 19:17, Sven Van Caekenberghe sven@stfx.eu mailto:sven@stfx.eu wrote:

Hi David,

On 10 Feb 2021, at 19:18, David@totallyobjects.com mailto:David@totallyobjects.com wrote:

I am using STON to objects out to disk. Up to two days ago, I was reading them in as Dictionaries and converting to objects from there. All of a sudden yesterday morning, I got an error saying that the association is only indexable with integers. Even so, I don't seem to be able to access the contents.

Fistly, any ideas why this has changed and secondly, any ideas how to fix it?

David
Totally Objects

Sent from my Huawei tablet

I am afraid I need more information.

Could you create a reproducible case ?
Do you have a stack trace ?

In any case, STON is a text format, that can be edited (in most cases, shared or circular references being hard to edit by hand).

Sven

Yes but I can’t see any resolution on GitHub > On 11 Feb 2021, at 15:36, hogoww <pierre.misse-chanabier@inria.fr> wrote: > > Are you on Pharo 8? > I think I encountered this bug not so long ago. > From your screenshot, it look like it https://github.com/pharo-project/pharo/issues/8411 <https://github.com/pharo-project/pharo/issues/8411>? > > Pierre > > On 11/02/2021 16:33, David Pennington wrote: >> I attach a couple of screen shots and a file containing the item that I am trying to open. What else can I supply? This has been working for a couple of weeks and suddenly doesn’t work. I save the JSON and then load it back again. I enclose a file with the JSON as contents. As you can see from the screenshot, the debugger shows it as a dictionary but the execution path takes it to an Association which is what I don’t understand. >> >> >> >> >>> On 10 Feb 2021, at 19:17, Sven Van Caekenberghe <sven@stfx.eu> <mailto:sven@stfx.eu> wrote: >>> >>> Hi David, >>> >>>> On 10 Feb 2021, at 19:18, David@totallyobjects.com <mailto:David@totallyobjects.com> wrote: >>>> >>>> I am using STON to objects out to disk. Up to two days ago, I was reading them in as Dictionaries and converting to objects from there. All of a sudden yesterday morning, I got an error saying that the association is only indexable with integers. Even so, I don't seem to be able to access the contents. >>>> >>>> Fistly, any ideas why this has changed and secondly, any ideas how to fix it? >>>> >>>> David >>>> Totally Objects >>>> >>>> Sent from my Huawei tablet >>> I am afraid I need more information. >>> >>> Could you create a reproducible case ? >>> Do you have a stack trace ? >>> >>> In any case, STON is a text format, that can be edited (in most cases, shared or circular references being hard to edit by hand). >>> >>> Sven
SV
Sven Van Caekenberghe
Thu, Feb 11, 2021 4:39 PM

I can parse the file data you provided:

STON fromString: '{#entryName:''Housekeeping'',#entryDate:Date[''2021-02-25Z''],#transactionID:''2021022501'',#entryAmount:-400/1s8,#entryCategory:''Housekeeping'',#entryDescription:''Housekeeping'',#match:nil}ousekeeping'',#match:nil}'

"a Dictionary(#entryAmount->-400.00000000s8 #entryCategory->'Housekeeping' #entryDate->25 February 2021 #entryDescription->'Housekeeping' #entryName->'Housekeeping' #match->nil #transactionID->'2021022501' )"

(BTW, this is STON not JSON).

What I do see in the input is junk after the last }

That can happen when you overwrite an existing file with shorter content. You should truncate such a file.

From your screenshot I can see nothing wrong, #entryAmount seems an existing key in aDict, that should just work.

On 11 Feb 2021, at 16:33, David Pennington david@totallyobjects.com wrote:

I attach a couple of screen shots and a file containing the item that I am trying to open. What else can I supply? This has been working for a couple of weeks and suddenly doesn’t work. I save the JSON and then load it back again. I enclose a file with the JSON as contents. As you can see from the screenshot, the debugger shows it as a dictionary but the execution path takes it to an Association which is what I don’t understand.

<stack.rtf><20210225 01><screenshot.png>

On 10 Feb 2021, at 19:17, Sven Van Caekenberghe sven@stfx.eu wrote:

Hi David,

On 10 Feb 2021, at 19:18, David@totallyobjects.com wrote:

I am using STON to objects out to disk. Up to two days ago, I was reading them in as Dictionaries and converting to objects from there. All of a sudden yesterday morning, I got an error saying that the association is only indexable with integers. Even so, I don't seem to be able to access the contents.

Fistly, any ideas why this has changed and secondly, any ideas how to fix it?

David
Totally Objects

Sent from my Huawei tablet

I am afraid I need more information.

Could you create a reproducible case ?
Do you have a stack trace ?

In any case, STON is a text format, that can be edited (in most cases, shared or circular references being hard to edit by hand).

Sven

I can parse the file data you provided: STON fromString: '{#entryName:''Housekeeping'',#entryDate:Date[''2021-02-25Z''],#transactionID:''2021022501'',#entryAmount:-400/1s8,#entryCategory:''Housekeeping'',#entryDescription:''Housekeeping'',#match:nil}ousekeeping'',#match:nil}' "a Dictionary(#entryAmount->-400.00000000s8 #entryCategory->'Housekeeping' #entryDate->25 February 2021 #entryDescription->'Housekeeping' #entryName->'Housekeeping' #match->nil #transactionID->'2021022501' )" (BTW, this is STON not JSON). What I do see in the input is junk after the last } That can happen when you overwrite an existing file with shorter content. You should truncate such a file. From your screenshot I can see nothing wrong, #entryAmount seems an existing key in aDict, that should just work. > On 11 Feb 2021, at 16:33, David Pennington <david@totallyobjects.com> wrote: > > I attach a couple of screen shots and a file containing the item that I am trying to open. What else can I supply? This has been working for a couple of weeks and suddenly doesn’t work. I save the JSON and then load it back again. I enclose a file with the JSON as contents. As you can see from the screenshot, the debugger shows it as a dictionary but the execution path takes it to an Association which is what I don’t understand. > > <stack.rtf><20210225 01><screenshot.png> > >> On 10 Feb 2021, at 19:17, Sven Van Caekenberghe <sven@stfx.eu> wrote: >> >> Hi David, >> >>> On 10 Feb 2021, at 19:18, David@totallyobjects.com wrote: >>> >>> I am using STON to objects out to disk. Up to two days ago, I was reading them in as Dictionaries and converting to objects from there. All of a sudden yesterday morning, I got an error saying that the association is only indexable with integers. Even so, I don't seem to be able to access the contents. >>> >>> Fistly, any ideas why this has changed and secondly, any ideas how to fix it? >>> >>> David >>> Totally Objects >>> >>> Sent from my Huawei tablet >> >> I am afraid I need more information. >> >> Could you create a reproducible case ? >> Do you have a stack trace ? >> >> In any case, STON is a text format, that can be edited (in most cases, shared or circular references being hard to edit by hand). >> >> Sven >
DP
David Pennington
Thu, Feb 11, 2021 4:46 PM

Thank you for that but it doesn’t resolve my problem. Why does the stack move to an Association when doing the access to the dictionary? It is the Association indexing that fails as it won’t allow #entryAmount as a key.

If I inspect the following code (STON fromString: result ) in the line ^ self makeObject: (STON fromString: result ) I get an Association. Why don’t I get a Dictionary. I did two days ago when all of this was working perfectly and we were happily matching the Pharo Seaside display to our bank account :=)

David

On 11 Feb 2021, at 16:39, Sven Van Caekenberghe sven@stfx.eu wrote:

I can parse the file data you provided:

STON fromString: '{#entryName:''Housekeeping'',#entryDate:Date[''2021-02-25Z''],#transactionID:''2021022501'',#entryAmount:-400/1s8,#entryCategory:''Housekeeping'',#entryDescription:''Housekeeping'',#match:nil}ousekeeping'',#match:nil}'

"a Dictionary(#entryAmount->-400.00000000s8 #entryCategory->'Housekeeping' #entryDate->25 February 2021 #entryDescription->'Housekeeping' #entryName->'Housekeeping' #match->nil #transactionID->'2021022501' )"

(BTW, this is STON not JSON).

What I do see in the input is junk after the last }

That can happen when you overwrite an existing file with shorter content. You should truncate such a file.

From your screenshot I can see nothing wrong, #entryAmount seems an existing key in aDict, that should just work.

On 11 Feb 2021, at 16:33, David Pennington david@totallyobjects.com wrote:

I attach a couple of screen shots and a file containing the item that I am trying to open. What else can I supply? This has been working for a couple of weeks and suddenly doesn’t work. I save the JSON and then load it back again. I enclose a file with the JSON as contents. As you can see from the screenshot, the debugger shows it as a dictionary but the execution path takes it to an Association which is what I don’t understand.

<stack.rtf><20210225 01><screenshot.png>

On 10 Feb 2021, at 19:17, Sven Van Caekenberghe sven@stfx.eu wrote:

Hi David,

On 10 Feb 2021, at 19:18, David@totallyobjects.com wrote:

I am using STON to objects out to disk. Up to two days ago, I was reading them in as Dictionaries and converting to objects from there. All of a sudden yesterday morning, I got an error saying that the association is only indexable with integers. Even so, I don't seem to be able to access the contents.

Fistly, any ideas why this has changed and secondly, any ideas how to fix it?

David
Totally Objects

Sent from my Huawei tablet

I am afraid I need more information.

Could you create a reproducible case ?
Do you have a stack trace ?

In any case, STON is a text format, that can be edited (in most cases, shared or circular references being hard to edit by hand).

Sven

Thank you for that but it doesn’t resolve my problem. Why does the stack move to an Association when doing the access to the dictionary? It is the Association indexing that fails as it won’t allow #entryAmount as a key. If I inspect the following code (STON fromString: result ) in the line ^ self makeObject: (STON fromString: result ) I get an Association. Why don’t I get a Dictionary. I did two days ago when all of this was working perfectly and we were happily matching the Pharo Seaside display to our bank account :=) David > On 11 Feb 2021, at 16:39, Sven Van Caekenberghe <sven@stfx.eu> wrote: > > I can parse the file data you provided: > > STON fromString: '{#entryName:''Housekeeping'',#entryDate:Date[''2021-02-25Z''],#transactionID:''2021022501'',#entryAmount:-400/1s8,#entryCategory:''Housekeeping'',#entryDescription:''Housekeeping'',#match:nil}ousekeeping'',#match:nil}' > > "a Dictionary(#entryAmount->-400.00000000s8 #entryCategory->'Housekeeping' #entryDate->25 February 2021 #entryDescription->'Housekeeping' #entryName->'Housekeeping' #match->nil #transactionID->'2021022501' )" > > (BTW, this is STON not JSON). > > What I do see in the input is junk after the last } > > That can happen when you overwrite an existing file with shorter content. You should truncate such a file. > > From your screenshot I can see nothing wrong, #entryAmount seems an existing key in aDict, that should just work. > >> On 11 Feb 2021, at 16:33, David Pennington <david@totallyobjects.com> wrote: >> >> I attach a couple of screen shots and a file containing the item that I am trying to open. What else can I supply? This has been working for a couple of weeks and suddenly doesn’t work. I save the JSON and then load it back again. I enclose a file with the JSON as contents. As you can see from the screenshot, the debugger shows it as a dictionary but the execution path takes it to an Association which is what I don’t understand. >> >> <stack.rtf><20210225 01><screenshot.png> >> >>> On 10 Feb 2021, at 19:17, Sven Van Caekenberghe <sven@stfx.eu> wrote: >>> >>> Hi David, >>> >>>> On 10 Feb 2021, at 19:18, David@totallyobjects.com wrote: >>>> >>>> I am using STON to objects out to disk. Up to two days ago, I was reading them in as Dictionaries and converting to objects from there. All of a sudden yesterday morning, I got an error saying that the association is only indexable with integers. Even so, I don't seem to be able to access the contents. >>>> >>>> Fistly, any ideas why this has changed and secondly, any ideas how to fix it? >>>> >>>> David >>>> Totally Objects >>>> >>>> Sent from my Huawei tablet >>> >>> I am afraid I need more information. >>> >>> Could you create a reproducible case ? >>> Do you have a stack trace ? >>> >>> In any case, STON is a text format, that can be edited (in most cases, shared or circular references being hard to edit by hand). >>> >>> Sven >>
P
peter@pbkresearch.co.uk
Thu, Feb 11, 2021 5:07 PM

David
I think you are misreading the debugger display. The bit you are missing is the last few characters in the evaluation display, after the closing parenthesis. They should not be there if it is displaying a dictionary. Evidently the variable 'aDict' is in fact an association whose key is the dictionary and whose value is nil.

I can't see where it goes from there, but I think you need to look more closely at the preceding line, FAOEntry>>getEntryObjectFrom:,  and see what exactly it does with the junk in your .dat file.

HTH

Peter Kenny

-----Original Message-----
From: David Pennington david@totallyobjects.com
Sent: 11 February 2021 16:46
To: Any question about pharo is welcome pharo-users@lists.pharo.org
Subject: [Pharo-users] Re: Problem with Dictionary and Associations

Thank you for that but it doesn’t resolve my problem. Why does the stack move to an Association when doing the access to the dictionary? It is the Association indexing that fails as it won’t allow #entryAmount as a key.

If I inspect the following code (STON fromString: result ) in the line ^ self makeObject: (STON fromString: result ) I get an Association. Why don’t I get a Dictionary. I did two days ago when all of this was working perfectly and we were happily matching the Pharo Seaside display to our bank account :=)

David

On 11 Feb 2021, at 16:39, Sven Van Caekenberghe sven@stfx.eu wrote:

I can parse the file data you provided:

STON fromString: '{#entryName:''Housekeeping'',#entryDate:Date[''2021-02-25Z''],#transactionID:''2021022501'',#entryAmount:-400/1s8,#entryCategory:''Housekeeping'',#entryDescription:''Housekeeping'',#match:nil}ousekeeping'',#match:nil}'

"a Dictionary(#entryAmount->-400.00000000s8 #entryCategory->'Housekeeping' #entryDate->25 February 2021 #entryDescription->'Housekeeping' #entryName->'Housekeeping' #match->nil #transactionID->'2021022501' )"

(BTW, this is STON not JSON).

What I do see in the input is junk after the last }

That can happen when you overwrite an existing file with shorter content. You should truncate such a file.

From your screenshot I can see nothing wrong, #entryAmount seems an existing key in aDict, that should just work.

On 11 Feb 2021, at 16:33, David Pennington david@totallyobjects.com wrote:

I attach a couple of screen shots and a file containing the item that I am trying to open. What else can I supply? This has been working for a couple of weeks and suddenly doesn’t work. I save the JSON and then load it back again. I enclose a file with the JSON as contents. As you can see from the screenshot, the debugger shows it as a dictionary but the execution path takes it to an Association which is what I don’t understand.

<stack.rtf><20210225 01><screenshot.png>

On 10 Feb 2021, at 19:17, Sven Van Caekenberghe sven@stfx.eu wrote:

Hi David,

On 10 Feb 2021, at 19:18, David@totallyobjects.com wrote:

I am using STON to objects out to disk. Up to two days ago, I was reading them in as Dictionaries and converting to objects from there. All of a sudden yesterday morning, I got an error saying that the association is only indexable with integers. Even so, I don't seem to be able to access the contents.

Fistly, any ideas why this has changed and secondly, any ideas how to fix it?

David
Totally Objects

Sent from my Huawei tablet

I am afraid I need more information.

Could you create a reproducible case ?
Do you have a stack trace ?

In any case, STON is a text format, that can be edited (in most cases, shared or circular references being hard to edit by hand).

Sven

David I think you are misreading the debugger display. The bit you are missing is the last few characters in the evaluation display, after the closing parenthesis. They should not be there if it is displaying a dictionary. Evidently the variable 'aDict' is in fact an association whose key is the dictionary and whose value is nil. I can't see where it goes from there, but I think you need to look more closely at the preceding line, FAOEntry>>getEntryObjectFrom:, and see what exactly it does with the junk in your .dat file. HTH Peter Kenny -----Original Message----- From: David Pennington <david@totallyobjects.com> Sent: 11 February 2021 16:46 To: Any question about pharo is welcome <pharo-users@lists.pharo.org> Subject: [Pharo-users] Re: Problem with Dictionary and Associations Thank you for that but it doesn’t resolve my problem. Why does the stack move to an Association when doing the access to the dictionary? It is the Association indexing that fails as it won’t allow #entryAmount as a key. If I inspect the following code (STON fromString: result ) in the line ^ self makeObject: (STON fromString: result ) I get an Association. Why don’t I get a Dictionary. I did two days ago when all of this was working perfectly and we were happily matching the Pharo Seaside display to our bank account :=) David > On 11 Feb 2021, at 16:39, Sven Van Caekenberghe <sven@stfx.eu> wrote: > > I can parse the file data you provided: > > STON fromString: '{#entryName:''Housekeeping'',#entryDate:Date[''2021-02-25Z''],#transactionID:''2021022501'',#entryAmount:-400/1s8,#entryCategory:''Housekeeping'',#entryDescription:''Housekeeping'',#match:nil}ousekeeping'',#match:nil}' > > "a Dictionary(#entryAmount->-400.00000000s8 #entryCategory->'Housekeeping' #entryDate->25 February 2021 #entryDescription->'Housekeeping' #entryName->'Housekeeping' #match->nil #transactionID->'2021022501' )" > > (BTW, this is STON not JSON). > > What I do see in the input is junk after the last } > > That can happen when you overwrite an existing file with shorter content. You should truncate such a file. > > From your screenshot I can see nothing wrong, #entryAmount seems an existing key in aDict, that should just work. > >> On 11 Feb 2021, at 16:33, David Pennington <david@totallyobjects.com> wrote: >> >> I attach a couple of screen shots and a file containing the item that I am trying to open. What else can I supply? This has been working for a couple of weeks and suddenly doesn’t work. I save the JSON and then load it back again. I enclose a file with the JSON as contents. As you can see from the screenshot, the debugger shows it as a dictionary but the execution path takes it to an Association which is what I don’t understand. >> >> <stack.rtf><20210225 01><screenshot.png> >> >>> On 10 Feb 2021, at 19:17, Sven Van Caekenberghe <sven@stfx.eu> wrote: >>> >>> Hi David, >>> >>>> On 10 Feb 2021, at 19:18, David@totallyobjects.com wrote: >>>> >>>> I am using STON to objects out to disk. Up to two days ago, I was reading them in as Dictionaries and converting to objects from there. All of a sudden yesterday morning, I got an error saying that the association is only indexable with integers. Even so, I don't seem to be able to access the contents. >>>> >>>> Fistly, any ideas why this has changed and secondly, any ideas how to fix it? >>>> >>>> David >>>> Totally Objects >>>> >>>> Sent from my Huawei tablet >>> >>> I am afraid I need more information. >>> >>> Could you create a reproducible case ? >>> Do you have a stack trace ? >>> >>> In any case, STON is a text format, that can be edited (in most cases, shared or circular references being hard to edit by hand). >>> >>> Sven >>
SV
Sven Van Caekenberghe
Thu, Feb 11, 2021 5:33 PM

Ah, I overlooked that as well ;-)

This could happen by STON input as follows

{ ... } : null

with everything after the closing } being junk from a previous file that you overwrote with shorter contents.

Try deleting or truncating your (existing) file first, for example using #ensureDelete.

On 11 Feb 2021, at 18:07, peter@pbkresearch.co.uk peter@pbkresearch.co.uk wrote:

David
I think you are misreading the debugger display. The bit you are missing is the last few characters in the evaluation display, after the closing parenthesis. They should not be there if it is displaying a dictionary. Evidently the variable 'aDict' is in fact an association whose key is the dictionary and whose value is nil.

I can't see where it goes from there, but I think you need to look more closely at the preceding line, FAOEntry>>getEntryObjectFrom:,  and see what exactly it does with the junk in your .dat file.

HTH

Peter Kenny

-----Original Message-----
From: David Pennington david@totallyobjects.com
Sent: 11 February 2021 16:46
To: Any question about pharo is welcome pharo-users@lists.pharo.org
Subject: [Pharo-users] Re: Problem with Dictionary and Associations

Thank you for that but it doesn’t resolve my problem. Why does the stack move to an Association when doing the access to the dictionary? It is the Association indexing that fails as it won’t allow #entryAmount as a key.

If I inspect the following code (STON fromString: result ) in the line ^ self makeObject: (STON fromString: result ) I get an Association. Why don’t I get a Dictionary. I did two days ago when all of this was working perfectly and we were happily matching the Pharo Seaside display to our bank account :=)

David

On 11 Feb 2021, at 16:39, Sven Van Caekenberghe sven@stfx.eu wrote:

I can parse the file data you provided:

STON fromString: '{#entryName:''Housekeeping'',#entryDate:Date[''2021-02-25Z''],#transactionID:''2021022501'',#entryAmount:-400/1s8,#entryCategory:''Housekeeping'',#entryDescription:''Housekeeping'',#match:nil}ousekeeping'',#match:nil}'

"a Dictionary(#entryAmount->-400.00000000s8 #entryCategory->'Housekeeping' #entryDate->25 February 2021 #entryDescription->'Housekeeping' #entryName->'Housekeeping' #match->nil #transactionID->'2021022501' )"

(BTW, this is STON not JSON).

What I do see in the input is junk after the last }

That can happen when you overwrite an existing file with shorter content. You should truncate such a file.

From your screenshot I can see nothing wrong, #entryAmount seems an existing key in aDict, that should just work.

On 11 Feb 2021, at 16:33, David Pennington david@totallyobjects.com wrote:

I attach a couple of screen shots and a file containing the item that I am trying to open. What else can I supply? This has been working for a couple of weeks and suddenly doesn’t work. I save the JSON and then load it back again. I enclose a file with the JSON as contents. As you can see from the screenshot, the debugger shows it as a dictionary but the execution path takes it to an Association which is what I don’t understand.

<stack.rtf><20210225 01><screenshot.png>

On 10 Feb 2021, at 19:17, Sven Van Caekenberghe sven@stfx.eu wrote:

Hi David,

On 10 Feb 2021, at 19:18, David@totallyobjects.com wrote:

I am using STON to objects out to disk. Up to two days ago, I was reading them in as Dictionaries and converting to objects from there. All of a sudden yesterday morning, I got an error saying that the association is only indexable with integers. Even so, I don't seem to be able to access the contents.

Fistly, any ideas why this has changed and secondly, any ideas how to fix it?

David
Totally Objects

Sent from my Huawei tablet

I am afraid I need more information.

Could you create a reproducible case ?
Do you have a stack trace ?

In any case, STON is a text format, that can be edited (in most cases, shared or circular references being hard to edit by hand).

Sven

Ah, I overlooked that as well ;-) This could happen by STON input as follows { ... } : null with everything after the closing } being junk from a previous file that you overwrote with shorter contents. Try deleting or truncating your (existing) file first, for example using #ensureDelete. > On 11 Feb 2021, at 18:07, <peter@pbkresearch.co.uk> <peter@pbkresearch.co.uk> wrote: > > David > I think you are misreading the debugger display. The bit you are missing is the last few characters in the evaluation display, after the closing parenthesis. They should not be there if it is displaying a dictionary. Evidently the variable 'aDict' is in fact an association whose key is the dictionary and whose value is nil. > > I can't see where it goes from there, but I think you need to look more closely at the preceding line, FAOEntry>>getEntryObjectFrom:, and see what exactly it does with the junk in your .dat file. > > HTH > > Peter Kenny > > > -----Original Message----- > From: David Pennington <david@totallyobjects.com> > Sent: 11 February 2021 16:46 > To: Any question about pharo is welcome <pharo-users@lists.pharo.org> > Subject: [Pharo-users] Re: Problem with Dictionary and Associations > > Thank you for that but it doesn’t resolve my problem. Why does the stack move to an Association when doing the access to the dictionary? It is the Association indexing that fails as it won’t allow #entryAmount as a key. > > If I inspect the following code (STON fromString: result ) in the line ^ self makeObject: (STON fromString: result ) I get an Association. Why don’t I get a Dictionary. I did two days ago when all of this was working perfectly and we were happily matching the Pharo Seaside display to our bank account :=) > > David > >> On 11 Feb 2021, at 16:39, Sven Van Caekenberghe <sven@stfx.eu> wrote: >> >> I can parse the file data you provided: >> >> STON fromString: '{#entryName:''Housekeeping'',#entryDate:Date[''2021-02-25Z''],#transactionID:''2021022501'',#entryAmount:-400/1s8,#entryCategory:''Housekeeping'',#entryDescription:''Housekeeping'',#match:nil}ousekeeping'',#match:nil}' >> >> "a Dictionary(#entryAmount->-400.00000000s8 #entryCategory->'Housekeeping' #entryDate->25 February 2021 #entryDescription->'Housekeeping' #entryName->'Housekeeping' #match->nil #transactionID->'2021022501' )" >> >> (BTW, this is STON not JSON). >> >> What I do see in the input is junk after the last } >> >> That can happen when you overwrite an existing file with shorter content. You should truncate such a file. >> >> From your screenshot I can see nothing wrong, #entryAmount seems an existing key in aDict, that should just work. >> >>> On 11 Feb 2021, at 16:33, David Pennington <david@totallyobjects.com> wrote: >>> >>> I attach a couple of screen shots and a file containing the item that I am trying to open. What else can I supply? This has been working for a couple of weeks and suddenly doesn’t work. I save the JSON and then load it back again. I enclose a file with the JSON as contents. As you can see from the screenshot, the debugger shows it as a dictionary but the execution path takes it to an Association which is what I don’t understand. >>> >>> <stack.rtf><20210225 01><screenshot.png> >>> >>>> On 10 Feb 2021, at 19:17, Sven Van Caekenberghe <sven@stfx.eu> wrote: >>>> >>>> Hi David, >>>> >>>>> On 10 Feb 2021, at 19:18, David@totallyobjects.com wrote: >>>>> >>>>> I am using STON to objects out to disk. Up to two days ago, I was reading them in as Dictionaries and converting to objects from there. All of a sudden yesterday morning, I got an error saying that the association is only indexable with integers. Even so, I don't seem to be able to access the contents. >>>>> >>>>> Fistly, any ideas why this has changed and secondly, any ideas how to fix it? >>>>> >>>>> David >>>>> Totally Objects >>>>> >>>>> Sent from my Huawei tablet >>>> >>>> I am afraid I need more information. >>>> >>>> Could you create a reproducible case ? >>>> Do you have a stack trace ? >>>> >>>> In any case, STON is a text format, that can be edited (in most cases, shared or circular references being hard to edit by hand). >>>> >>>> Sven >>>
DP
David Pennington
Thu, Feb 11, 2021 7:38 PM

Hi there Peter

I have been writing Smalltalk since 1990 first with Digitalk and then IBM/Instantiations VAST. However, I am a newbie with Pharo having only used it for the last 3 weeks so I am pleased to have got my first Seaside app working successfully - it’s a home banking management app that imports from Sage compatible CSV files supplied by NatWest. This is the only real difficulty so I am very pleased with the work.

I use my own brand key/value database that saves objects out to the disk. With my new M1 MacBookAir, I am getting read and write values around .3 second for 125 records so I am very happy.

I have yet to look at deleting the old file before writing but I am sure that this will make it superb.

Many thanks for your help in this.

David
TotallyObjects
http://www.totallyobjects http://www.totallyobjects/.com

Your suggestion worked perfectly - I truncate the file and it parses

On 11 Feb 2021, at 17:07, peter@pbkresearch.co.uk peter@pbkresearch.co.uk wrote:

David
I think you are misreading the debugger display. The bit you are missing is the last few characters in the evaluation display, after the closing parenthesis. They should not be there if it is displaying a dictionary. Evidently the variable 'aDict' is in fact an association whose key is the dictionary and whose value is nil.

I can't see where it goes from there, but I think you need to look more closely at the preceding line, FAOEntry>>getEntryObjectFrom:,  and see what exactly it does with the junk in your .dat file.

HTH

Peter Kenny

-----Original Message-----
From: David Pennington david@totallyobjects.com
Sent: 11 February 2021 16:46
To: Any question about pharo is welcome pharo-users@lists.pharo.org
Subject: [Pharo-users] Re: Problem with Dictionary and Associations

Thank you for that but it doesn’t resolve my problem. Why does the stack move to an Association when doing the access to the dictionary? It is the Association indexing that fails as it won’t allow #entryAmount as a key.

If I inspect the following code (STON fromString: result ) in the line ^ self makeObject: (STON fromString: result ) I get an Association. Why don’t I get a Dictionary. I did two days ago when all of this was working perfectly and we were happily matching the Pharo Seaside display to our bank account :=)

David

On 11 Feb 2021, at 16:39, Sven Van Caekenberghe sven@stfx.eu wrote:

I can parse the file data you provided:

STON fromString: '{#entryName:''Housekeeping'',#entryDate:Date[''2021-02-25Z''],#transactionID:''2021022501'',#entryAmount:-400/1s8,#entryCategory:''Housekeeping'',#entryDescription:''Housekeeping'',#match:nil}ousekeeping'',#match:nil}'

"a Dictionary(#entryAmount->-400.00000000s8 #entryCategory->'Housekeeping' #entryDate->25 February 2021 #entryDescription->'Housekeeping' #entryName->'Housekeeping' #match->nil #transactionID->'2021022501' )"

(BTW, this is STON not JSON).

What I do see in the input is junk after the last }

That can happen when you overwrite an existing file with shorter content. You should truncate such a file.

From your screenshot I can see nothing wrong, #entryAmount seems an existing key in aDict, that should just work.

On 11 Feb 2021, at 16:33, David Pennington david@totallyobjects.com wrote:

I attach a couple of screen shots and a file containing the item that I am trying to open. What else can I supply? This has been working for a couple of weeks and suddenly doesn’t work. I save the JSON and then load it back again. I enclose a file with the JSON as contents. As you can see from the screenshot, the debugger shows it as a dictionary but the execution path takes it to an Association which is what I don’t understand.

<stack.rtf><20210225 01><screenshot.png>

On 10 Feb 2021, at 19:17, Sven Van Caekenberghe sven@stfx.eu wrote:

Hi David,

On 10 Feb 2021, at 19:18, David@totallyobjects.com wrote:

I am using STON to objects out to disk. Up to two days ago, I was reading them in as Dictionaries and converting to objects from there. All of a sudden yesterday morning, I got an error saying that the association is only indexable with integers. Even so, I don't seem to be able to access the contents.

Fistly, any ideas why this has changed and secondly, any ideas how to fix it?

David
Totally Objects

Sent from my Huawei tablet

I am afraid I need more information.

Could you create a reproducible case ?
Do you have a stack trace ?

In any case, STON is a text format, that can be edited (in most cases, shared or circular references being hard to edit by hand).

Sven

Hi there Peter I have been writing Smalltalk since 1990 first with Digitalk and then IBM/Instantiations VAST. However, I am a newbie with Pharo having only used it for the last 3 weeks so I am pleased to have got my first Seaside app working successfully - it’s a home banking management app that imports from Sage compatible CSV files supplied by NatWest. This is the only real difficulty so I am very pleased with the work. I use my own brand key/value database that saves objects out to the disk. With my new M1 MacBookAir, I am getting read and write values around .3 second for 125 records so I am very happy. I have yet to look at deleting the old file before writing but I am sure that this will make it superb. Many thanks for your help in this. David TotallyObjects http://www.totallyobjects <http://www.totallyobjects/>.com Your suggestion worked perfectly - I truncate the file and it parses > On 11 Feb 2021, at 17:07, <peter@pbkresearch.co.uk> <peter@pbkresearch.co.uk> wrote: > > David > I think you are misreading the debugger display. The bit you are missing is the last few characters in the evaluation display, after the closing parenthesis. They should not be there if it is displaying a dictionary. Evidently the variable 'aDict' is in fact an association whose key is the dictionary and whose value is nil. > > I can't see where it goes from there, but I think you need to look more closely at the preceding line, FAOEntry>>getEntryObjectFrom:, and see what exactly it does with the junk in your .dat file. > > HTH > > Peter Kenny > > > -----Original Message----- > From: David Pennington <david@totallyobjects.com> > Sent: 11 February 2021 16:46 > To: Any question about pharo is welcome <pharo-users@lists.pharo.org> > Subject: [Pharo-users] Re: Problem with Dictionary and Associations > > Thank you for that but it doesn’t resolve my problem. Why does the stack move to an Association when doing the access to the dictionary? It is the Association indexing that fails as it won’t allow #entryAmount as a key. > > If I inspect the following code (STON fromString: result ) in the line ^ self makeObject: (STON fromString: result ) I get an Association. Why don’t I get a Dictionary. I did two days ago when all of this was working perfectly and we were happily matching the Pharo Seaside display to our bank account :=) > > David > >> On 11 Feb 2021, at 16:39, Sven Van Caekenberghe <sven@stfx.eu> wrote: >> >> I can parse the file data you provided: >> >> STON fromString: '{#entryName:''Housekeeping'',#entryDate:Date[''2021-02-25Z''],#transactionID:''2021022501'',#entryAmount:-400/1s8,#entryCategory:''Housekeeping'',#entryDescription:''Housekeeping'',#match:nil}ousekeeping'',#match:nil}' >> >> "a Dictionary(#entryAmount->-400.00000000s8 #entryCategory->'Housekeeping' #entryDate->25 February 2021 #entryDescription->'Housekeeping' #entryName->'Housekeeping' #match->nil #transactionID->'2021022501' )" >> >> (BTW, this is STON not JSON). >> >> What I do see in the input is junk after the last } >> >> That can happen when you overwrite an existing file with shorter content. You should truncate such a file. >> >> From your screenshot I can see nothing wrong, #entryAmount seems an existing key in aDict, that should just work. >> >>> On 11 Feb 2021, at 16:33, David Pennington <david@totallyobjects.com> wrote: >>> >>> I attach a couple of screen shots and a file containing the item that I am trying to open. What else can I supply? This has been working for a couple of weeks and suddenly doesn’t work. I save the JSON and then load it back again. I enclose a file with the JSON as contents. As you can see from the screenshot, the debugger shows it as a dictionary but the execution path takes it to an Association which is what I don’t understand. >>> >>> <stack.rtf><20210225 01><screenshot.png> >>> >>>> On 10 Feb 2021, at 19:17, Sven Van Caekenberghe <sven@stfx.eu> wrote: >>>> >>>> Hi David, >>>> >>>>> On 10 Feb 2021, at 19:18, David@totallyobjects.com wrote: >>>>> >>>>> I am using STON to objects out to disk. Up to two days ago, I was reading them in as Dictionaries and converting to objects from there. All of a sudden yesterday morning, I got an error saying that the association is only indexable with integers. Even so, I don't seem to be able to access the contents. >>>>> >>>>> Fistly, any ideas why this has changed and secondly, any ideas how to fix it? >>>>> >>>>> David >>>>> Totally Objects >>>>> >>>>> Sent from my Huawei tablet >>>> >>>> I am afraid I need more information. >>>> >>>> Could you create a reproducible case ? >>>> Do you have a stack trace ? >>>> >>>> In any case, STON is a text format, that can be edited (in most cases, shared or circular references being hard to edit by hand). >>>> >>>> Sven >>>