Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

[RFC] Implement custom iterator for JSONArray to ensure fetched values are JSON compliant

Ouverte
#673 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
5/5
Temps estimé
Plus d'une semaine
Accessibilité débutants
25/100
Type d'issue
Bug
Clarté
À clarifier
Activité
À l'abandon
Stack technique
java
Domaine
backend

Piste de recherche

Start with JSONArray.iterator and review the related behavior in JSONObject, JSONArray put* operations, and toString methods; issue #672 provides the referenced context. Decide between lazy iterator wrapping and proactive wrapping during insertion, then verify that code-built values exposed to JSON processors are compliant without changing parsed objects.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Active discussion Fix before the next release

This has been a "known" issue for some time, but as mentioned in #672, the JSONArray.iterator method is exposing the raw values from the backing array instead of JSON-compliant values.

We should do 1 of 2 things:

  1. Implement a private/internal JSONArrayIterator class that would ensure any fetched values are properly "wrapped" and thus suitable output to JSON processors.
  2. Update all of our put* operations to ensure that all values are properly "wrapped" in both JSONObject and JSONArray. This would also allow us to simplify our toString methods and remove the wrapping from there as all values should be proper JSON.

Option 1 keeps the wrapping "lazy" and thus would only guarantee JSON compliance on values that are fetched. Fetching a non-wrapped value multiple times would cause wrapping to happen each time.

Option 2 makes the wrapping more proactive; guaranteeing that our JSON compliance happens up-front even if the value is not fetched later. Fetching an initially non-wrapped value multiple times would cause NO wrapping to happen at fetch as it would have been pre-wrapped by the put operation.

Both options only affect code-built JSONObjects/Arrays. Parsed objects would be unaffected as the parser is only placing JSON-compliant values in the backing collections.

Thoughts on whether we should implement either option, something else, or neither?

Langage dominant
Java
Étoiles
4.7k
Forks
2.6k
Merge moyen
6 j 20 h
PR mergées (30 j)
2

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de stleary/JSON-java

Toutes les issues de stleary/JSON-java

Issues similaires

Plus d'issues Java

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.