This Japanese folk tale that you refer to is an excellent example of somebody getting their just desserts. The wife of the old man starts off as a jealous and selfish character who is clearly unimportant to everybody. She is said to be "greedy and quarrelsome whenever anyone came her way who she could possibly quarrel with." The story does seem to have a two-part structure, with firstly the focus being on the man, and then on his wife. It is the man who plays with the sparrow and protects it, then it is the wife that abuses it. It is the man who finds the sparrow in human form and selects the smaller chest. Then it is the wife's turn. This meant that for me, the plot line was foreshadowed. It was clear that the wife would go to the sparrow's house and demand the larger chest due to her greed that was highlighted in the first paragraph of the story. What I wasn't sure about was what would be in the chest:
At length, however, the lock gave way, and the lid flew open, when, O horror! instead of gold and jewels, she saw before her serpents with glittering eyes and forky tongues. And they twined themselves about her and darted poison into her veins, and she died, and no man regretted her.
Although it was obvious that something would be in there that would take her life, the serpents are an excellent symbol of the woman's own jealousy and greed, that acts like a poison in her bloodstream and kills her just as effectively as the snakes themselves. Therefore I felt that the ending of this story was very strongly foreshadowed.