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 5, 2026 05:25Andrew EpsteinAndrew EpsteinScore: 2,390Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 5, 2026 06:312,35630,659,33413,066,0008,380,00092,741,632
2Nov 5, 2026 06:312,38130,899,87713,083,0008,589,00092,758,016
3Nov 5, 2026 06:312,38430,927,87713,177,0008,525,00092,774,400
4Nov 5, 2026 06:312,38830,975,89213,078,0008,660,00092,737,536
5Nov 5, 2026 06:312,39030,949,42813,161,0008,592,00092,696,576
6Nov 5, 2026 06:312,39431,169,36913,206,0008,583,00092,741,632
7Nov 5, 2026 06:312,40331,085,80613,281,0008,590,00092,737,536
8Nov 5, 2026 06:312,40731,263,10913,258,0008,653,00092,790,784
9Nov 5, 2026 06:312,41331,312,52013,292,0008,674,00092,770,304