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 21:57Andrew EpsteinAndrew EpsteinScore: 3,585Success
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 22:123,55642,583,31224,070,0008,291,00092,753,920
2Sep 14, 2026 22:123,56442,604,38423,965,0008,476,00092,766,208
3Sep 14, 2026 22:123,58042,764,33724,173,0008,407,00092,770,304
4Sep 14, 2026 22:123,58442,925,15524,190,0008,431,00092,745,728
5Sep 14, 2026 22:123,58542,969,44324,190,0008,442,00092,717,056
6Sep 14, 2026 22:123,59542,925,36024,228,0008,488,00092,749,824
7Sep 14, 2026 22:123,59842,982,58024,380,0008,363,00092,811,264
8Sep 14, 2026 22:123,60043,132,47724,400,0008,366,00092,753,920
9Sep 14, 2026 22:123,62043,860,83224,442,0008,508,00092,737,536