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:01Josu San MartinJosu San MartinScore: 8,958Success
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 03:538,913110,639,90160,078,00021,027,00094,748,672
2Jan 18, 2026 03:538,919103,143,69560,122,00021,042,00094,732,288
3Jan 18, 2026 03:538,923101,696,28863,156,00018,044,00094,785,536
4Jan 18, 2026 03:538,943110,228,72960,539,00020,841,00094,687,232
5Jan 18, 2026 03:538,953113,251,78258,341,00023,135,00094,625,792
6Jan 18, 2026 03:538,956110,624,18962,617,00018,884,00094,666,752
7Jan 18, 2026 04:018,958106,221,67062,628,00018,887,00094,666,752
8Jan 18, 2026 04:018,963109,081,59255,380,00026,179,00094,658,560
9Jan 18, 2026 03:538,979106,529,87559,786,00021,921,00094,666,752
10Jan 18, 2026 04:018,992110,566,73955,884,00025,946,00094,666,752
11Jan 18, 2026 03:539,011106,850,47455,002,00027,001,00094,625,792
12Jan 18, 2026 03:539,063113,938,06556,323,00026,150,00094,658,560