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,186Success
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 01:583,15539,547,60920,257,0008,460,00092,729,344
2Nov 3, 2026 01:583,17239,756,97420,382,0008,492,00092,770,304
3Nov 3, 2026 01:583,18040,427,52120,418,0008,529,00092,778,496
4Nov 3, 2026 01:583,18140,370,88620,469,0008,483,00092,696,576
5Nov 3, 2026 01:583,18641,131,14520,457,0008,543,00092,749,824
6Nov 3, 2026 01:583,18840,494,91220,288,0008,727,00092,770,304
7Nov 3, 2026 01:583,19139,936,81320,500,0008,545,00092,741,632
8Nov 3, 2026 01:583,21040,686,59920,567,0008,646,00092,729,344
9Nov 3, 2026 01:583,21540,098,76120,662,0008,600,00092,758,016