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 11, 2026 01:41Victor MerckléVictor MerckléScore: 2,856Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 11, 2026 01:502,84534,838,53917,182,0008,709,00092,803,072
2Jun 11, 2026 01:502,84734,938,43517,013,0008,901,00092,815,360
3Jun 11, 2026 01:502,84934,994,48117,030,0008,903,00092,786,688
4Jun 11, 2026 01:502,85235,075,23617,026,0008,930,00092,712,960
5Jun 11, 2026 01:502,85636,008,39117,080,0008,913,00092,782,592
6Jun 11, 2026 01:502,86434,966,10717,096,0008,967,00092,803,072
7Jun 11, 2026 01:502,87435,090,00917,131,0009,026,00092,778,496
8Jun 11, 2026 01:502,87635,103,68217,116,0009,061,00092,778,496
9Jun 11, 2026 01:502,87835,148,70617,128,0009,067,00092,790,784