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 06:45Josu San MartinJosu San MartinScore: 5,233Success
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 06:455,20069,997,54533,227,00014,096,00094,552,064
2Jan 18, 2026 06:455,20170,557,65734,240,00013,091,00094,552,064
3Jan 18, 2026 06:455,20271,081,76732,230,00015,107,00094,674,944
4Jan 18, 2026 06:455,21773,375,11329,295,00018,183,00094,552,064
5Jan 18, 2026 06:455,22280,937,74229,322,00018,200,00094,666,752
6Jan 18, 2026 06:455,22371,971,15423,764,00023,764,00094,789,632
7Jan 18, 2026 06:455,23370,798,96525,792,00021,824,00094,552,064
8Jan 18, 2026 06:455,23778,605,38225,816,00021,844,00094,670,848
9Jan 18, 2026 06:455,24475,625,31225,849,00021,872,00094,666,752
10Jan 18, 2026 06:455,25675,661,42128,895,00018,931,00094,679,040
11Jan 18, 2026 06:455,26676,172,09824,957,00022,960,00094,679,040
12Jan 18, 2026 06:455,26972,772,42825,973,00021,977,00094,679,040