[RFC] Implement custom iterator for JSONArray to ensure fetched values are JSON compliant
还没有人认领这个 Issue。
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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:
- Implement a private/internal
JSONArrayIteratorclass that would ensure any fetched values are properly "wrapped" and thus suitable output to JSON processors. - Update all of our
put*operations to ensure that all values are properly "wrapped" in bothJSONObjectandJSONArray. This would also allow us to simplify ourtoStringmethods 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?
- 主要语言
- Java
- 星标
- 4.7k
- 派生
- 2.6k
- 平均合并
- 11 天 18 分钟
- 30 天内合并 PR
- 1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
stleary/JSON-java 的其他 Issue
-
Fix before the next release
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 76/100
-
难度 2/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 82/100
-
Fix before the next release
难度 2/5 1-3 小时 新手友好度 78/100
查看 stleary/JSON-java 的全部 Issue
相似的 Issue
-
Bug Java Platform: Java
难度 2/5 1-3 小时 新手友好度 78/100
getsentry/sentry-java#6138 · 1 条评论 ·
-
bug needs triage p2
难度 2/5 1-3 小时 新手友好度 78/100
GoogleCloudPlatform/DataflowTemplates#4273 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 76/100
-
bug needs triage
难度 2/5 1-3 小时 新手友好度 76/100