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 listNov 3, 2026 04:58Andrew EpsteinAndrew EpsteinScore: 2,610Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 3, 2026 05:162,59734,504,87514,753,0008,883,00092,778,496
2Nov 3, 2026 05:162,59935,072,60514,832,0008,824,00092,741,632
3Nov 3, 2026 05:162,60235,831,01414,914,0008,765,00092,758,016
4Nov 3, 2026 05:162,61035,151,32514,923,0008,829,00092,770,304
5Nov 3, 2026 05:162,61034,556,28514,946,0008,806,00092,770,304
6Nov 3, 2026 05:162,61234,574,62414,909,0008,864,00092,741,632
7Nov 3, 2026 05:162,63337,145,51615,052,0008,909,00092,708,864
8Nov 3, 2026 05:162,63534,871,05815,070,0008,917,00092,753,920
9Nov 3, 2026 05:162,65335,536,72715,184,0008,962,00092,725,248