json4s / json4s/json4s

convert xml to json

Open
#682 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug enhancement
Dominant language
Scala
Stars
1.5k
Forks
324
Avg merge
4h 35m
Merged PRs (30d)
30

Description

json4s version

3.7.0-M4

scala version

2.12.10

jdk version

1.8

I have one xml just like:

<Teacher id="1">
    <name>Jim</name>
    <contact phone="123456" id="2">
        <color>blue</color>
    </contact>
</Teacher>

When I convert this xml to json, it looks nice:
{"Teacher":{"id":"1","name":"Jim","contact":{"phone":"123456","id":"2","color":"blue"}}}

But if I remove the "color" tag, just like:

<Teacher id="1">
    <name>Jim</name>
    <contact phone="123456" id="2"></contact>
</Teacher>

It would get this json result:
{"Teacher":{"id":"1","name":"Jim","phone":"123456","id":"2"}}
actually I think the "contact" tag should be Map structure

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the XML-to-JSON conversion with the two examples in the issue, then trace the json4s XML conversion entry point to see how an empty contact element is handled. Done means the contact element remains a nested map when it has attributes but no child elements, with tests covering both examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.