eclipse-ee4j / eclipse-ee4j/parsson

JsonParser returns empty string

Open
#10 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
17
Forks
25
PR merge metrics
No merged PRs in 30d

Description

Background
=======
I'm working on a program which takes JSON (an exported Trello board), and formats it into a list (each card in a custom format). The beginning process starts by going to the next node in the new JsonParser until it finds the array's key "cards". This works perfectly fine and does eventually find the key.

Bug
==
The problem occurs during the collection process. At this point, I have the event set to OBJECT_START, and I've already checked if there is a next value. After this, I go into a do-while loop:

1. Check the event to see how it should be interpreted (create the item, store the current item, get the key, or use the key to store the value in the item).
2. Get the next node and store the returned event.
3. Repeat while the parser has a next value.

The first cycle works perfectly fine. But on the next cycle when the event is set to KEY_NAME and I call getString, the returned string is "", when it should have been "id".

Workaround
========
To resolve this in the mean time, I switched to a while loop (the reverse order, and I do not skip the array's start before the collection process):

1. While the parser has a next value.
2. Get the next node and store the returned event.
3. Check the event to see how it should be interpreted.

This works, but it is undesirable (I already know that there is a next value at the beginning of the loop and should not have to check again).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.