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 listSep 14, 2026 02:22Andrew EpsteinAndrew EpsteinScore: 3,488Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 14, 2026 02:343,47341,921,92623,001,0008,608,00092,770,304
2Sep 14, 2026 02:343,48041,926,71323,055,0008,617,00092,725,248
3Sep 14, 2026 02:343,48442,751,82123,207,0008,500,00092,782,592
4Sep 14, 2026 02:343,48542,759,42523,255,0008,464,00092,717,056
5Sep 14, 2026 02:343,48842,533,49323,081,0008,668,00092,737,536
6Sep 14, 2026 02:343,49142,815,86323,159,0008,618,00092,770,304
7Sep 14, 2026 02:343,50342,936,33023,119,0008,763,00092,696,576
8Sep 14, 2026 02:343,50442,989,19823,126,0008,763,00092,688,384
9Sep 14, 2026 02:343,50742,924,71723,317,0008,605,00092,704,768