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 04:20Andrew EpsteinAndrew EpsteinScore: 2,741Success
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 04:362,71535,546,38316,254,0008,460,00092,778,496
2Nov 3, 2026 04:362,72735,637,56816,374,0008,447,00092,721,152
3Nov 3, 2026 04:362,73735,672,11016,398,0008,512,00092,753,920
4Nov 3, 2026 04:362,74036,068,19416,421,0008,513,00092,770,304
5Nov 3, 2026 04:362,74135,847,33816,357,0008,593,00092,745,728
6Nov 3, 2026 04:362,74336,303,71616,410,0008,553,00092,770,304
7Nov 3, 2026 04:362,74835,821,45016,437,0008,578,00092,696,576
8Nov 3, 2026 04:362,74935,830,47616,422,0008,594,00092,758,016
9Nov 3, 2026 04:362,76336,616,74916,574,0008,574,00092,704,768