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 19, 2026 04:15Charles CabergsCharles CabergsScore: 10,975Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 19, 2026 04:1510,946125,787,70979,688,00019,922,00094,556,160
2Apr 19, 2026 04:1510,957128,441,54576,776,00022,933,00094,556,160
3Apr 19, 2026 04:1510,958133,188,88280,774,00018,947,00094,556,160
4Apr 19, 2026 04:1510,960133,609,45675,802,00023,937,00094,556,160
5Apr 19, 2026 04:1510,975130,914,65480,894,00018,975,00094,801,920
6Apr 19, 2026 04:1510,989123,268,03382,998,00016,999,00094,560,256
7Apr 19, 2026 04:1510,990125,343,84482,004,00018,001,00094,539,776
8Apr 19, 2026 04:1511,004120,854,55984,113,00016,021,00094,547,968
9Apr 19, 2026 04:1511,058127,208,37580,702,00019,926,00094,715,904