Clear QJson Objcts/Arrays



  • Hello on the other screen,

    i´m looking for a way to clear QJson Objects/Arrays. My OS is Windows 7.
    My situation is, that i´m implementing a statemachine which is doing measurments in each case and the machine is triggered cyclic.
    So i can´t use Json Objects/Arrays in this way "QJsonObject myObjct" because it would vanish at the end of every cycle.
    I tried to do it by using dynamic allocation, but it feels like the envoironment doesn´t like that.
    When i make it like "static QJsonObject myObjct" i guess i would have to clear the Objects/Arrays for the next sequence when all measurements are done and saved to the file.
    How do i clear the Json Obcts/Arrays? Especially i´m asking because i´m not sure what happens behind the scenes and what i have to take into consideration when appending Objects to arrays and assining arrays to objects.

    best regards,
    Moe


  • Moderators

    @Flaming-Moe said:

    How do i clear the Json Obcts/Arrays?

    Just assign an empty object/array to your variable:

    myObjct = QJsonObject();
    

    Or, use QJsonObject::erase()/QJsonArray::erase()


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.