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 01:37Andrew EpsteinAndrew EpsteinScore: 3,465Success
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 02:043,43942,202,61622,910,0008,385,00092,745,728
2Nov 3, 2026 02:043,45642,262,00623,041,0008,409,00092,762,112
3Nov 3, 2026 02:043,45842,289,61723,035,0008,433,00092,778,496
4Nov 3, 2026 02:043,46342,810,47722,894,0008,625,00092,786,688
5Nov 3, 2026 02:043,46542,896,03523,054,0008,484,00092,737,536
6Nov 3, 2026 02:043,47143,013,76823,072,0008,518,00092,708,864
7Nov 3, 2026 02:043,47342,507,91123,073,0008,538,00092,790,784
8Nov 3, 2026 02:043,49743,210,37423,064,0008,759,00092,762,112
9Nov 3, 2026 02:043,50742,708,08723,280,0008,638,00092,688,384