XML to JSON Sergey Svistunov

Convert 1,000,000 person records from XML to JSON as fast as possible.

Input

XML document on STDIN:

<?xml version="1.0" encoding="UTF-8"?>
<persons>
    <person id="1512376">
        <age>30</age>
        <height>169.1</height>
        <married>true</married>
        <phone code="+6"><number>1283603279</number></phone>
        <phone code="+6"><number>1659964668</number></phone>
    </person>
    ...
</persons>

Output

One JSON object per person to STDOUT, preserving order:

{
    "id": 1512376,
    "age": 30,
    "height": 169.1,
    "married": true,
    "phones": [
        {
            "code": "+6",
            "number": 1283603279
        },
        {
            "code": "+6",
            "number": 1659964668
        }
    ]
}

Constraints

  • Preserve the order of persons
  • Omit the phones field if the phone array is empty
  • Maximum number of phones per person is 3
Back to listJul 7, 2026 04:38Victor MerckléVictor MerckléScore: 6,532Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 7, 2026 04:476,39367,635,86930,157,00028,026,00092,966,912stderr
2Jul 7, 2026 04:476,43468,096,08230,155,00028,401,00092,868,608stderr
3Jul 7, 2026 04:476,45068,350,89130,149,00028,548,00092,983,296stderr
4Jul 7, 2026 04:476,48968,524,48630,173,00028,884,00092,962,816stderr
5Jul 7, 2026 04:476,53268,943,66930,229,00029,221,00092,930,048stderr
6Jul 7, 2026 04:476,53669,223,71530,238,00029,240,00092,975,104stderr
7Jul 7, 2026 04:476,59569,513,44630,233,00029,788,00092,950,528stderr
8Jul 7, 2026 04:476,75570,894,82530,337,00031,136,00092,889,088stderr
9Jul 7, 2026 04:476,76370,934,70230,491,00031,056,00092,938,240stderr