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:54Andrew EpsteinAndrew EpsteinScore: 5,042Success
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:105,01356,427,74337,358,0008,269,00092,790,784
2Nov 3, 2026 02:105,03557,183,06137,461,0008,358,00092,725,248
3Nov 3, 2026 02:105,03757,168,94037,442,0008,395,00092,782,592
4Nov 3, 2026 02:105,03956,641,20937,474,0008,383,00092,766,208
5Nov 3, 2026 02:105,04256,812,70637,455,0008,428,00092,733,440
6Nov 3, 2026 02:105,04256,736,12037,410,0008,473,00092,737,536
7Nov 3, 2026 02:105,04557,298,69737,502,0008,415,00092,712,960
8Nov 3, 2026 02:105,05157,301,61737,493,0008,480,00092,680,192
9Nov 3, 2026 02:105,05457,411,25837,502,0008,497,00092,733,440