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 listFeb 19, 2026 05:18Josu San MartinJosu San MartinScore: 4,142Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Feb 19, 2026 05:184,09563,810,93418,129,00019,136,00094,670,848
2Feb 19, 2026 05:184,10769,824,86619,192,00018,182,00094,674,944
3Feb 19, 2026 05:184,11461,350,86320,235,00017,199,00094,646,272
4Feb 19, 2026 05:184,11864,307,16417,218,00020,257,00094,666,752
5Feb 19, 2026 05:274,12064,542,15917,227,00020,267,00094,556,160
6Feb 19, 2026 05:184,12765,777,80720,300,00017,255,00094,674,944
7Feb 19, 2026 05:184,12965,649,68518,788,00018,788,00094,556,160
8Feb 19, 2026 05:184,13864,428,07718,829,00018,829,00094,670,848
9Feb 19, 2026 05:184,13967,264,41021,806,00015,859,00094,789,632
10Feb 19, 2026 05:184,14267,723,13621,824,00015,872,00094,793,728
11Feb 19, 2026 05:184,14263,642,29620,828,00016,860,00094,556,160
12Feb 19, 2026 05:274,14368,632,06220,837,00016,868,00094,556,160
13Feb 19, 2026 05:184,14470,849,54718,857,00018,857,00094,662,656
14Feb 19, 2026 05:184,15163,786,92819,880,00017,892,00094,556,160
15Feb 19, 2026 05:184,15367,556,99920,883,00016,905,00094,556,160
16Feb 19, 2026 05:184,15667,782,49621,897,00015,925,00094,687,232
17Feb 19, 2026 05:184,16269,530,28120,929,00016,943,00094,679,040
18Feb 19, 2026 05:274,16768,778,20719,957,00017,961,00094,556,160
19Feb 19, 2026 05:184,17366,165,10521,984,00015,988,00094,674,944
20Feb 19, 2026 05:184,17561,677,42820,995,00016,996,00094,679,040
21Feb 19, 2026 05:184,19560,405,52519,089,00019,089,00094,556,160