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 listJun 28, 2026 20:04Shikhar SoniShikhar SoniScore: 5,308Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 28, 2026 20:105,26957,264,74926,625,00021,324,00094,392,320
2Jun 28, 2026 20:105,27457,482,59926,604,00021,391,00094,392,320
3Jun 28, 2026 20:105,28557,460,46226,682,00021,420,00094,392,320
4Jun 28, 2026 20:105,28657,373,53026,595,00021,516,00094,392,320
5Jun 28, 2026 20:105,30857,554,43026,681,00021,625,00094,392,320
6Jun 28, 2026 20:105,31758,021,61926,727,00021,660,00094,392,320
7Jun 28, 2026 20:105,38358,408,06026,401,00022,586,00094,392,320
8Jun 28, 2026 20:105,46659,443,45226,079,00023,665,00094,392,320
9Jun 28, 2026 20:105,50359,827,57925,952,00024,133,00094,392,320