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 listMay 3, 2026 18:34TudyMTudyMScore: 8,402Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 3, 2026 18:398,35791,635,86159,259,00016,792,00094,638,080
2May 3, 2026 18:398,37193,160,91259,319,00016,859,00094,638,080
3May 3, 2026 18:398,38790,774,89258,744,00017,580,00094,633,984
4May 3, 2026 18:398,38896,058,46958,794,00017,541,00094,642,176
5May 3, 2026 18:398,40295,065,09859,224,00017,240,00094,642,176
6May 3, 2026 18:398,40390,390,26858,914,00017,562,00094,629,888
7May 3, 2026 18:398,40492,978,55559,147,00017,335,00094,638,080
8May 3, 2026 18:398,40492,469,97759,493,00016,989,00094,642,176
9May 3, 2026 18:398,41292,772,69759,209,00017,341,00094,642,176