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 08:46Andrew EpsteinAndrew EpsteinScore: 2,423Success
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 08:572,39831,201,23713,448,0008,375,00092,725,248
2Nov 3, 2026 08:572,40831,218,71113,389,0008,527,00092,729,344
3Nov 3, 2026 08:572,41731,472,42513,490,0008,506,00092,774,400
4Nov 3, 2026 08:572,42131,348,08013,530,0008,509,00092,725,248
5Nov 3, 2026 08:572,42331,210,10213,566,0008,488,00092,749,824
6Nov 3, 2026 08:572,43131,631,22613,547,0008,581,00092,798,976
7Nov 3, 2026 08:572,43531,471,63613,536,0008,623,00092,745,728
8Nov 3, 2026 08:572,44031,463,63513,560,0008,645,00092,794,880
9Nov 3, 2026 08:572,46531,745,76613,677,0008,756,00092,712,960