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 listJun 12, 2026 17:06Victor MerckléVictor MerckléScore: 2,681Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 12, 2026 17:122,66131,682,25815,555,0008,664,00092,729,344
2Jun 12, 2026 17:122,66931,805,54415,577,0008,714,00092,737,536
3Jun 12, 2026 17:122,67131,765,97715,573,0008,737,00092,758,016
4Jun 12, 2026 17:122,67932,011,49615,642,0008,737,00092,704,768
5Jun 12, 2026 17:122,68132,065,83315,675,0008,723,00092,733,440
6Jun 12, 2026 17:122,69132,496,02315,693,0008,803,00092,753,920
7Jun 12, 2026 17:122,69332,095,58715,620,0008,892,00092,721,152
8Jun 12, 2026 17:122,69732,587,04715,690,0008,861,00092,741,632
9Jun 12, 2026 17:122,69933,653,04815,693,0008,873,00092,717,056