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 listNov 3, 2026 05:06Andrew EpsteinAndrew EpsteinScore: 2,586Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 3, 2026 05:282,57634,362,70114,595,0008,852,00092,753,920
2Nov 3, 2026 05:282,57834,875,67214,855,0008,610,00092,770,304
3Nov 3, 2026 05:282,58334,992,07814,654,0008,856,00092,758,016
4Nov 3, 2026 05:282,58335,101,48114,649,0008,858,00092,790,784
5Nov 3, 2026 05:282,58634,524,71914,672,0008,867,00092,753,920
6Nov 3, 2026 05:282,58634,375,30614,601,0008,934,00092,725,248
7Nov 3, 2026 05:282,58634,339,99014,710,0008,830,00092,790,784
8Nov 3, 2026 05:282,60136,533,00914,975,0008,701,00092,725,248
9Nov 3, 2026 05:282,61135,152,14114,815,0008,954,00092,753,920