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 listNov 3, 2026 04:41Andrew EpsteinAndrew EpsteinScore: 3,018Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 3, 2026 05:112,97738,008,95218,608,0008,491,00092,721,152
2Nov 3, 2026 05:112,98237,978,36418,658,0008,486,00092,712,960
3Nov 3, 2026 05:112,98538,039,17018,675,0008,491,00092,770,304
4Nov 3, 2026 05:112,98638,032,54318,678,0008,495,00092,684,288
5Nov 3, 2026 05:113,01839,379,01018,834,0008,630,00092,753,920
6Nov 3, 2026 05:113,01940,438,82918,896,0008,582,00092,778,496
7Nov 3, 2026 05:113,02038,867,20818,813,0008,670,00092,758,016
8Nov 3, 2026 05:113,02538,910,52418,851,0008,681,00092,729,344
9Nov 3, 2026 05:113,02838,967,64418,868,0008,692,00092,782,592