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 listDec 24, 2025 01:15Josu San MartinJosu San MartinScore: 31,034Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 24, 2025 01:1530,838307,823,885261,655,00018,975,00094,601,216
2Dec 24, 2025 01:1530,962305,229,158261,772,00019,982,00094,617,600
3Dec 24, 2025 01:1530,995304,706,690264,052,00018,003,00094,617,600
4Dec 24, 2025 01:1530,997305,278,864264,069,00018,004,00094,572,544
5Dec 24, 2025 01:1531,034312,678,011263,385,00019,027,00094,785,536
6Dec 24, 2025 01:1531,260308,801,187262,508,00021,958,00094,584,832
7Dec 24, 2025 01:1531,359318,562,859267,408,00017,960,00094,785,536
8Dec 24, 2025 01:1531,420313,630,389264,927,00020,994,00094,789,632
9Dec 24, 2025 01:1532,640321,975,626268,025,00029,002,00094,560,256