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:08Josu San MartinJosu San MartinScore: 5,946Success
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:085,92176,600,11932,927,00020,953,00094,666,752
2Jan 18, 2026 06:085,92576,930,89533,948,00019,969,00094,670,848
3Jan 18, 2026 06:085,92880,013,18230,967,00022,975,00094,662,656
4Jan 18, 2026 06:085,94279,319,63532,045,00022,031,00094,662,656
5Jan 18, 2026 06:085,94676,681,53531,060,00023,045,00094,674,944
6Jan 18, 2026 06:085,94877,106,16433,078,00021,049,00094,552,064
7Jan 18, 2026 06:085,95777,359,33929,113,00025,097,00094,552,064
8Jan 18, 2026 06:085,96175,807,32131,141,00023,105,00094,679,040
9Jan 18, 2026 06:086,00683,254,35433,788,00020,869,00094,670,848