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 18, 2026 08:01Charles CabergsCharles CabergsScore: 12,783Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 18, 2026 08:0112,747143,356,07499,000,00017,000,00094,556,160
2Apr 18, 2026 08:0112,758138,327,531101,082,00015,012,00094,556,160
3Apr 18, 2026 08:0112,763139,701,266100,121,00016,019,00094,789,632
4Apr 18, 2026 08:0112,771139,222,176102,189,00014,026,00094,801,920
5Apr 18, 2026 08:0112,783140,654,17599,279,00017,048,00094,543,872
6Apr 18, 2026 08:0112,805147,331,051101,589,00014,939,00094,801,920
7Apr 18, 2026 08:0112,808145,141,568100,478,00016,076,00094,658,560
8Apr 18, 2026 08:0112,808144,391,94796,633,00019,924,00094,752,768
9Apr 18, 2026 08:0112,827143,609,74398,767,00017,957,00094,625,792