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 18:44Charles CabergsCharles CabergsScore: 5,465Success
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 18:465,41669,364,12930,175,00019,111,00094,801,920
2Apr 22, 2026 18:465,42164,697,37229,197,00020,135,00094,793,728
3Apr 22, 2026 18:465,42664,175,84032,251,00017,133,00094,789,632
4Apr 22, 2026 18:465,42866,472,55231,252,00018,146,00094,793,728
5Apr 22, 2026 18:465,46569,295,14229,843,00019,895,00094,793,728
6Apr 22, 2026 18:465,48066,048,06329,923,00019,948,00094,793,728
7Apr 22, 2026 18:465,51469,842,38127,553,00022,632,00094,797,824
8Apr 22, 2026 18:465,78774,089,17335,775,00016,894,00094,797,824
9Apr 22, 2026 18:465,86173,266,41435,224,00018,115,00094,793,728