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 29, 2026 23:58Charles CabergsCharles CabergsScore: 4,005Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 30, 2026 00:003,97753,849,80219,104,00017,093,00094,793,728
2Apr 30, 2026 00:003,97951,241,08817,100,00019,111,00094,801,920
3Apr 30, 2026 00:003,98554,966,73018,133,00018,133,00094,806,016
4Apr 30, 2026 00:003,98657,816,09420,152,00016,122,00094,797,824
5Apr 30, 2026 00:004,00553,854,85820,251,00016,200,00094,797,824
6Apr 30, 2026 00:004,01855,417,51618,283,00018,283,00094,609,408
7Apr 30, 2026 00:004,02158,125,34618,793,00017,804,00094,806,016
8Apr 30, 2026 00:004,02856,389,52719,347,00017,310,00094,797,824
9Apr 30, 2026 00:004,04854,829,86017,924,00018,920,00094,797,824