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 listApr 29, 2026 15:57Charles CabergsCharles CabergsScore: 4,018Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 29, 2026 15:593,99353,199,08217,162,00019,181,00094,793,728
2Apr 29, 2026 15:593,99655,100,61117,172,00019,192,00094,609,408
3Apr 29, 2026 15:594,00657,199,45117,217,00019,242,00094,793,728
4Apr 29, 2026 15:594,00750,297,18418,233,00018,233,00094,609,408
5Apr 29, 2026 15:594,01855,669,68017,792,00018,780,00094,797,824
6Apr 29, 2026 15:594,01953,018,43817,792,00018,781,00094,801,920
7Apr 29, 2026 15:594,02054,397,31019,308,00017,276,00094,789,632
8Apr 29, 2026 15:594,02252,953,55317,808,00018,798,00094,597,120
9Apr 29, 2026 15:594,02255,901,91718,301,00018,301,00094,789,632