JSONML checks childNode instead of the reserved childNodes attribute
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- java
- Domain
- backend-api-design
Research direction
Start at JSONML.parse(), where the reserved-attribute check is shown, and trace the object-form path that later stores children under childNodes. Add regression coverage for rejecting childNodes while preserving childNode, then run the relevant JSONML tests or test suite and confirm array-form parsing remains unchanged.
Written by the indexing model from the issue text.
Description
The reserved-attribute check in JSONML.toJSONObject() checks childNode (singular), although the object representation uses childNodes (plural). As a result, a childNodes attribute is silently overwritten by the element's children, while an ordinary childNode attribute is rejected.
Reproduced on release 20260814 and current master (874673575807723d58bbec9ff1985668742940ce), with Java 17.0.20:
import org.json.JSONML;
System.out.println(JSONML.toJSONObject(
"<p childNodes=\"metadata\">text</p>", true));
// {"childNodes":["text"],"tagName":"p"} -- attribute lost
System.out.println(JSONML.toJSONObject(
"<p childNode=\"metadata\">text</p>", true));
// JSONException: Reserved attribute.
Expected: reject childNodes as reserved, as already happens for tagName, and preserve childNode as a regular attribute.
The check is in JSONML.parse(): "tagName".equals(attribute) || "childNode".equals(attribute). Later in the same method, newjo.put("childNodes", newja) overwrites the accepted attribute. Array-form parsing preserves both attribute names, so this affects the object form.
- Dominant language
- Java
- Stars
- 4.7k
- Forks
- 2.6k
- Avg merge
- 6d 20h
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from stleary/JSON-java
-
Fix before the next release
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Fix before the next release
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Active discussion
Difficulty 5/5 Over a week Newbie friendliness 35/100
All issues in stleary/JSON-java
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100