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
Date AuthorLanguageStatus Score
Mar 4, 2026 03:18olliecrowolliecrowCPPclang++18.1.3Success10,696
Mar 4, 2026 03:12olliecrowolliecrowCPPclang++18.1.3Success10,662+26.83 RP
Mar 4, 2026 03:03olliecrowolliecrowCPPclang++18.1.3Success11,016
Mar 4, 2026 02:41olliecrowolliecrowCPPclang++18.1.3Success10,983
Mar 4, 2026 02:36olliecrowolliecrowCPPclang++18.1.3Success10,976+1.66 RP
Mar 4, 2026 02:33olliecrowolliecrowCPPclang++18.1.3Success11,014
Mar 4, 2026 02:23Josu San MartinJosu San MartinCSHARP9.0.13Success4,740+1'562.12 RP
Mar 4, 2026 02:18olliecrowolliecrowCPPclang++18.1.3Success10,996+18.63 RP
Mar 4, 2026 02:09olliecrowolliecrowCPPclang++18.1.3Success11,226+6.46 RP
Mar 4, 2026 02:07olliecrowolliecrowCPPclang++18.1.3Success11,308+3.35 RP
Mar 4, 2026 02:03olliecrowolliecrowCPPclang++18.1.3Success11,351+17.94 RP
Mar 4, 2026 01:59olliecrowolliecrowCPPclang++18.1.3Success11,587+14.28 RP
Mar 4, 2026 01:55olliecrowolliecrowCPPclang++18.1.3Success11,787
Mar 4, 2026 01:50olliecrowolliecrowCPPclang++18.1.3Success11,782+0.43 RP
Mar 4, 2026 01:45olliecrowolliecrowCPPclang++18.1.3Success11,896
Mar 4, 2026 01:44olliecrowolliecrowCPPclang++18.1.3Error
Mar 4, 2026 01:42olliecrowolliecrowCPPclang++18.1.3Error
Mar 4, 2026 01:41olliecrowolliecrowCPPclang++18.1.3Error
Mar 4, 2026 01:32olliecrowolliecrowCPPclang++18.1.3Success13,611
Mar 4, 2026 01:28olliecrowolliecrowCPPg++13.3.0Success16,379
Mar 4, 2026 01:27olliecrowolliecrowCPPclang++18.1.3Success13,799
Mar 4, 2026 01:24olliecrowolliecrowCPPclang++18.1.3Success12,369
Mar 4, 2026 01:05olliecrowolliecrowCPPclang++18.1.3Success11,790
Mar 4, 2026 00:56olliecrowolliecrowCPPclang++18.1.3Error
Mar 4, 2026 00:52olliecrowolliecrowCPPclang++18.1.3Error
Mar 4, 2026 00:39olliecrowolliecrowCPPclang++18.1.3Success12,382
Mar 4, 2026 00:36olliecrowolliecrowCPPclang++18.1.3Success11,843
Mar 4, 2026 00:27olliecrowolliecrowCPPclang++18.1.3Success11,788+1.58 RP
Mar 4, 2026 00:23olliecrowolliecrowCPPclang++18.1.3Success13,362
Mar 4, 2026 00:19olliecrowolliecrowCPPclang++18.1.3Success11,810+9.22 RP
Mar 4, 2026 00:15olliecrowolliecrowCPPclang++18.1.3Success11,940+6.54 RP
Mar 4, 2026 00:09olliecrowolliecrowCPPclang++18.1.3Success12,034+19.03 RP
Mar 4, 2026 00:00olliecrowolliecrowCPPclang++18.1.3Success12,316+65.91 RP
Mar 3, 2026 23:55olliecrowolliecrowCPPclang++18.1.3Success13,432
Mar 3, 2026 23:51olliecrowolliecrowCPPclang++18.1.3Success13,404+121.24 RP
Mar 3, 2026 23:47olliecrowolliecrowCPPclang++18.1.3Success26,790
Mar 3, 2026 23:42olliecrowolliecrowCPPclang++18.1.3Success36,511
Mar 3, 2026 23:38olliecrowolliecrowCPPclang++18.1.3Error
Mar 3, 2026 23:34olliecrowolliecrowCPPclang++18.1.3Success16,005+0.23 RP
Mar 3, 2026 23:29olliecrowolliecrowCPPclang++18.1.3Error
Mar 3, 2026 23:25olliecrowolliecrowCPPclang++18.1.3Error
Mar 3, 2026 23:18olliecrowolliecrowCPPclang++18.1.3Error
Mar 3, 2026 23:16olliecrowolliecrowCPPclang++18.1.3Error
Mar 3, 2026 23:15olliecrowolliecrowCPPclang++18.1.3Error
Mar 3, 2026 23:07olliecrowolliecrowCPPg++13.3.0Success21,388
Mar 3, 2026 23:01olliecrowolliecrowCPPclang++18.1.3Error
Mar 3, 2026 22:57olliecrowolliecrowCPPclang++18.1.3Error
Mar 3, 2026 22:52olliecrowolliecrowCPPclang++18.1.3Error
Mar 3, 2026 22:46olliecrowolliecrowCPPclang++18.1.3Success16,042
Mar 3, 2026 22:41olliecrowolliecrowCPPclang++18.1.3Success16,030
Mar 3, 2026 22:39olliecrowolliecrowCPPclang++18.1.3Error
Mar 3, 2026 22:38olliecrowolliecrowCPPg++13.3.0Success21,514
Mar 3, 2026 22:36olliecrowolliecrowCPPclang++18.1.3Success16,011+0.97 RP
Mar 3, 2026 22:31olliecrowolliecrowCPPclang++18.1.3Success16,036+2.40 RP
Mar 3, 2026 22:27olliecrowolliecrowCPPclang++18.1.3Success16,098+318.37 RP
Mar 3, 2026 22:24olliecrowolliecrowCPPg++13.3.0Error
Mar 3, 2026 22:21olliecrowolliecrowCPPg++13.3.0Success33,022+302.83 RP
Feb 19, 2026 05:18Josu San MartinJosu San MartinCPPg++13.3.0Success4,142+128.58 RP
Feb 19, 2026 04:46Josu San MartinJosu San MartinCPPg++13.3.0Success4,375+32.95 RP
Jan 23, 2026 16:44Josu San MartinJosu San MartinRUSTrust-1.92.0Success4,586
Jan 23, 2026 03:53Josu San MartinJosu San MartinRUSTrust-1.92.0Success4,521
Jan 23, 2026 03:50Josu San MartinJosu San MartinRUSTrust-1.92.0Success4,522
Jan 23, 2026 03:46Josu San MartinJosu San MartinRUSTrust-1.92.0Success4,439+72.40 RP
Jan 23, 2026 03:39Josu San MartinJosu San MartinRUSTrust-1.92.0Success4,516+58.71 RP
Jan 23, 2026 03:36Josu San MartinJosu San MartinRUSTrust-1.92.0Error
Jan 23, 2026 03:36Josu San MartinJosu San MartinRUSTrust-1.92.0Error
Jan 23, 2026 03:26Josu San MartinJosu San MartinRUSTrust-1.92.0Success4,675
Jan 23, 2026 03:03Josu San MartinJosu San MartinRUSTrust-1.92.0Success4,639+158.43 RP
Jan 23, 2026 02:55Josu San MartinJosu San MartinRUSTrust-1.92.0Success11,289
Jan 18, 2026 19:05Josu San MartinJosu San MartinCPPg++13.3.0Success4,938
Jan 18, 2026 19:05Josu San MartinJosu San MartinCPPg++13.3.0Success5,211
Jan 18, 2026 07:15Josu San MartinJosu San MartinCPPg++13.3.0Success4,507+277.40 RP
Jan 18, 2026 07:13Josu San MartinJosu San MartinCPPg++13.3.0Success5,276
Jan 18, 2026 07:13Josu San MartinJosu San MartinCPPg++13.3.0Success5,355
Jan 18, 2026 07:13Josu San MartinJosu San MartinCPPg++13.3.0Success5,345
Jan 18, 2026 07:09Josu San MartinJosu San MartinCPPg++13.3.0Success5,262
Jan 18, 2026 07:08Josu San MartinJosu San MartinCPPg++13.3.0Success5,181
Jan 18, 2026 07:08Josu San MartinJosu San MartinCPPg++13.3.0Success5,151+24.19 RP
Jan 18, 2026 07:02Josu San MartinJosu San MartinCPPg++13.3.0Success5,407
Jan 18, 2026 06:45Josu San MartinJosu San MartinCPPg++13.3.0Success5,229
Jan 18, 2026 06:45Josu San MartinJosu San MartinCPPg++13.3.0Success5,233
Jan 18, 2026 06:42Josu San MartinJosu San MartinCPPg++13.3.0Success8,420
Jan 18, 2026 06:39Josu San MartinJosu San MartinCPPg++13.3.0Success9,641
Jan 18, 2026 06:39Josu San MartinJosu San MartinCPPg++13.3.0Success9,576
Jan 18, 2026 06:36Josu San MartinJosu San MartinCPPg++13.3.0Error
Jan 18, 2026 06:30Josu San MartinJosu San MartinCPPg++13.3.0Success5,250
Jan 18, 2026 06:25Josu San MartinJosu San MartinCPPg++13.3.0Success5,218
Jan 18, 2026 06:24Josu San MartinJosu San MartinCPPg++13.3.0Success5,216+180.16 RP
Jan 18, 2026 06:20Josu San MartinJosu San MartinCPPg++13.3.0Success5,846
Jan 18, 2026 06:19Josu San MartinJosu San MartinCPPg++13.3.0Success5,809
Jan 18, 2026 06:19Josu San MartinJosu San MartinCPPg++13.3.0Success5,836
Jan 18, 2026 06:18Josu San MartinJosu San MartinCPPg++13.3.0Success5,902
Jan 18, 2026 06:16Josu San MartinJosu San MartinCPPg++13.3.0Success5,869
Jan 18, 2026 06:13Josu San MartinJosu San MartinCPPg++13.3.0Success10,998
Jan 18, 2026 06:11Josu San MartinJosu San MartinCPPg++13.3.0Success5,757+55.21 RP
Jan 18, 2026 06:11Josu San MartinJosu San MartinCPPclang++18.1.3Success6,269
Jan 18, 2026 06:08Josu San MartinJosu San MartinCPPg++13.3.0Success5,946+78.72 RP
Jan 18, 2026 05:59Josu San MartinJosu San MartinCPPg++13.3.0Success6,238+38.62 RP
Jan 18, 2026 05:53Josu San MartinJosu San MartinCPPg++13.3.0Success6,392+137.11 RP
Jan 18, 2026 05:52Josu San MartinJosu San MartinCPPg++13.3.0Success7,046