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 22, 2026 16:37Charles CabergsCharles CabergsScore: 5,962Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 22, 2026 16:395,93574,397,01836,007,00018,003,00094,793,728
2Apr 22, 2026 16:395,94971,826,59535,089,00019,048,00094,793,728
3Apr 22, 2026 16:395,95472,278,61533,116,00021,074,00094,609,408
4Apr 22, 2026 16:395,96071,559,93337,166,00017,076,00094,793,728
5Apr 22, 2026 16:395,96272,349,17038,181,00016,076,00094,806,016
6Apr 22, 2026 16:395,97075,897,50436,219,00018,109,00094,781,440
7Apr 22, 2026 16:395,97373,366,09537,246,00017,113,00094,781,440
8Apr 22, 2026 16:395,99268,937,69736,687,00017,847,00094,588,928
9Apr 22, 2026 16:396,02074,078,02036,857,00017,930,00094,806,016