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 07:28Andrew EpsteinAndrew EpsteinScore: 2,433Success
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 07:342,42331,344,08313,537,0008,517,00092,766,208
2Nov 3, 2026 07:342,42731,490,41013,542,0008,550,00092,733,440
3Nov 3, 2026 07:342,43131,567,92513,566,0008,562,00092,721,152
4Nov 3, 2026 07:342,43131,523,57513,587,0008,543,00092,745,728
5Nov 3, 2026 07:342,43332,952,73813,577,0008,567,00092,688,384
6Nov 3, 2026 07:342,43631,430,49313,678,0008,493,00092,741,632
7Nov 3, 2026 07:342,43833,257,84913,634,0008,557,00092,721,152
8Nov 3, 2026 07:342,43931,441,53613,572,0008,625,00092,758,016
9Nov 3, 2026 07:342,45431,607,84313,690,0008,644,00092,721,152