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 listJan 23, 2026 03:39Josu San MartinJosu San MartinScore: 4,516Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jan 23, 2026 03:394,48164,338,32625,859,00014,918,00094,629,888
2Jan 23, 2026 03:394,49265,824,75826,919,00013,958,00094,633,984
3Jan 23, 2026 03:394,51065,704,31522,022,00019,019,00094,560,256
4Jan 23, 2026 03:394,51266,157,79325,038,00016,024,00094,560,256
5Jan 23, 2026 03:394,51665,468,35224,055,00017,039,00094,560,256
6Jan 23, 2026 03:394,52160,386,78223,077,00018,060,00094,638,080
7Jan 23, 2026 03:394,53767,091,02425,177,00016,113,00094,560,256
8Jan 23, 2026 03:394,54864,041,47725,234,00016,150,00094,560,256
9Jan 23, 2026 03:394,54871,537,92824,228,00017,162,00094,646,272