VirtualBox

Ignore:
Timestamp:
Sep 21, 2018 6:23:01 PM (6 years ago)
Author:
vboxsync
Message:

IPRT/rest: Reworked the JSON output classes a little, adding a pretty printing version. bugref:9167

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/rest/RTCRestArrayBase.cpp

    r74402 r74414  
    3434#include <iprt/err.h>
    3535#include <iprt/string.h>
     36#include <iprt/cpp/restoutput.h>
    3637
    3738
     
    117118    if (!m_fNullIndicator)
    118119    {
    119         a_rDst.printf("[\n");
    120         unsigned const uOldIndent = a_rDst.incrementIndent();
    121 
     120        uint32_t const uOldState = a_rDst.beginArray();
    122121        for (size_t i = 0; i < m_cElements; i++)
    123122        {
     123            a_rDst.valueSeparator();
    124124            m_papElements[i]->serializeAsJson(a_rDst);
    125             if (i < m_cElements - 1)
    126                 a_rDst.printf(",\n");
    127             else
    128                 a_rDst.printf("\n");
    129         }
    130 
    131         a_rDst.setIndent(uOldIndent);
    132         a_rDst.printf("]");
     125        }
     126        a_rDst.endArray(uOldState);
    133127    }
    134128    else
    135         a_rDst.printf("null");
     129        a_rDst.nullValue();
    136130    return a_rDst;
    137131}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette