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 listJan 18, 2026 04:03Josu San MartinJosu San MartinScore: 8,934Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jan 18, 2026 04:038,867110,946,32556,784,00023,909,00094,658,560
2Jan 18, 2026 04:038,875111,041,51758,830,00021,936,00094,662,656
3Jan 18, 2026 04:038,929108,927,68263,198,00018,056,00094,687,232
4Jan 18, 2026 04:038,932105,274,67858,199,00023,079,00094,654,464
5Jan 18, 2026 04:038,934106,765,58156,207,00025,092,00094,703,616
6Jan 18, 2026 04:038,945106,187,05963,308,00018,088,00094,662,656
7Jan 18, 2026 04:038,947109,954,46361,560,00019,858,00094,683,136
8Jan 18, 2026 04:038,953112,184,76360,348,00021,122,00094,658,560
9Jan 18, 2026 04:038,975107,965,14061,755,00019,921,00094,662,656