[BR] JUCE Assertion failure in juce_JSONSerialisation.h:484

Since last update i have an assertion failure parsing my preferences file.

JUCE Assertion failure in juce_JSONSerialisation.h:484

It worked perfectly fine before. :unamused:

I need to investigate to understand what’s going on…

I force the type of entries when parsing them at load.

struct Cast {

template <class T> static T fromVar (const juce::var& v)
{
    return juce::VariantConverter<T>::fromVar (v);
}

template <class T> static juce::var toVar (const T& t)
{
    return juce::VariantConverter<T>::toVar (t);
}

template <class T> static juce::var force (const juce::var& v)
{
    return toVar<T> (fromVar<T> (v));
}

};

Now for bool (such as below) it fails (since behaviour of juce::VariantConverter has changed).

<?xml version="1.0" encoding="UTF-8"?>

<PREFERENCES>
  <GROUP name="General" hidden="0">
    <PARAMETER value="1" key="AskBeforeQuit"/>
    <PARAMETER value="0" key="DefaultIsRunView"/>
  </GROUP>
</PREFERENCES>
juce::var Parameter::forceType (const juce::var& v) const
{
    if (isBoolean())        { return Cast::force<bool> (v);   }
    else if (isInteger())   { return Cast::force<int> (v);    }
    else if (isFloat())     { return Cast::force<double> (v); }
    else if (isColour())    { return Cast::force<juce::Colour> (v); }
    else if (isRectangle()) { return Cast::force<juce::Rectangle<int>> (v); }
    else {
        return Cast::force<juce::String> (v);
    }
}

Thanks for reporting, the old behaviour is restored in this commit:

1 Like

Thanks ; works fine now.