Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonParser returns empty string #10

Open
glassfishrobot opened this issue Nov 13, 2017 · 1 comment
Open

JsonParser returns empty string #10

glassfishrobot opened this issue Nov 13, 2017 · 1 comment

Comments

@glassfishrobot
Copy link

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).

@glassfishrobot
Copy link
Author

@lukasj lukasj transferred this issue from jakartaee/jsonp-api Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant