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 12:33BenBenScore: 21,528Success
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 12:3721,439219,713,810174,091,00021,011,00094,777,344
2Apr 22, 2026 12:3721,475214,929,443170,503,00024,927,00094,597,120
3Apr 22, 2026 12:3721,475212,128,113170,497,00024,926,00094,748,672
4Apr 22, 2026 12:3721,501213,943,213171,702,00023,958,00094,773,248
5Apr 22, 2026 12:3721,528215,326,204171,920,00023,988,00094,666,752
6Apr 22, 2026 12:3721,551220,384,734174,106,00022,013,00094,785,536
7Apr 22, 2026 12:3721,634215,821,771171,888,00024,983,00094,777,344
8Apr 22, 2026 12:3721,666215,825,898170,282,00026,886,00094,781,440
9Apr 22, 2026 12:3721,780218,332,886176,183,00022,022,00094,777,344