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 07:46Andrew EpsteinAndrew EpsteinScore: 2,441Success
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 07:512,43133,369,61813,601,0008,525,00092,684,288
2Nov 3, 2026 07:512,43531,521,46513,588,0008,574,00092,766,208
3Nov 3, 2026 07:512,43631,412,28113,645,0008,530,00092,704,768
4Nov 3, 2026 07:512,44031,547,61013,689,0008,523,00092,762,112
5Nov 3, 2026 07:512,44131,529,14713,680,0008,534,00092,676,096
6Nov 3, 2026 07:512,44731,726,03413,716,0008,558,00092,815,360
7Nov 3, 2026 07:512,46131,727,26113,758,0008,641,00092,684,288
8Nov 3, 2026 07:512,46331,680,53713,843,0008,571,00092,794,880
9Nov 3, 2026 07:512,47032,255,53113,824,0008,658,00092,692,480