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 listJul 12, 2025 13:18Aniruddha DebAniruddha DebScore: 2,991Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 12, 2025 13:182,97751,398,12220,065,0007,022,00094,527,488
2Jul 12, 2025 13:182,97748,000,68220,068,0007,023,00094,556,160
3Jul 12, 2025 13:182,97748,453,07419,067,0008,028,00094,502,912
4Jul 12, 2025 13:182,97854,124,63920,077,0007,026,00094,334,976
5Jul 12, 2025 13:182,99150,021,06819,151,0008,063,00094,593,024
6Jul 12, 2025 13:182,99147,152,09719,152,0008,064,00094,507,008
7Jul 12, 2025 13:182,99749,873,15318,184,0009,092,00094,371,840
8Jul 12, 2025 13:183,00550,706,71020,253,0007,088,00094,625,792
9Jul 12, 2025 13:183,00748,758,94219,259,0008,109,00094,593,024