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 listAug 19, 2026 14:28Victor MerckléVictor MerckléScore: 2,411Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 19, 2026 14:342,39030,252,18513,063,0008,695,00092,749,824stderr
2Aug 19, 2026 14:342,39631,011,62112,934,0008,877,00092,737,536stderr
3Aug 19, 2026 14:342,41037,344,13013,183,0008,757,00092,729,344stderr
4Aug 19, 2026 14:342,41030,502,67912,994,0008,938,00092,749,824stderr
5Aug 19, 2026 14:342,41130,996,92613,238,0008,708,00092,745,728stderr
6Aug 19, 2026 14:342,41930,422,10613,375,0008,642,00092,774,400stderr
7Aug 19, 2026 14:342,42431,080,01013,314,0008,747,00092,745,728stderr
8Aug 19, 2026 14:342,43039,726,11613,464,0008,651,00092,794,880stderr
9Aug 19, 2026 14:342,44138,373,58213,692,0008,527,00092,741,632stderr