bool ValueAnimation::SaveJSON(JSONValue& dest) const
{
    dest.Set("interpolationmethod", interpMethodNames[interpolationMethod_]);
    if (interpolationMethod_ == IM_SPLINE)
        dest.Set("splinetension", (float) splineTension_);

    JSONArray keyFramesArray;
    keyFramesArray.Reserve(keyFrames_.Size());
    for (unsigned i = 0; i < keyFrames_.Size(); ++i)
    {
        const VAnimKeyFrame& keyFrame = keyFrames_[i];
        JSONValue keyFrameVal;
        keyFrameVal.Set("time", keyFrame.time_);
        JSONValue valueVal;
        valueVal.SetVariant(keyFrame.value_);
        keyFrameVal.Set("value", valueVal);
        keyFramesArray.Push(keyFrameVal);
    }
    dest.Set("keyframes", keyFramesArray);

    JSONArray eventFramesArray;
    eventFramesArray.Reserve(eventFrames_.Size());
    for (unsigned i = 0; i < eventFrames_.Size(); ++i)
    {
        const VAnimEventFrame& eventFrame = eventFrames_[i];
        JSONValue eventFrameVal;
        eventFrameVal.Set("time", eventFrame.time_);
        eventFrameVal.Set("eventtype", eventFrame.eventType_.Value());
        JSONValue eventDataVal;
        eventDataVal.SetVariantMap(eventFrame.eventData_);
        eventFrameVal.Set("eventdata", eventDataVal);

        eventFramesArray.Push(eventFrameVal);
    }
    dest.Set("eventframes", eventFramesArray);

    return true;
}
bool UnknownComponent::SaveJSON(JSONValue& dest) const
{
    if (!useXML_)
        ATOMIC_LOGWARNING("UnknownComponent loaded in binary mode, attributes will be empty for JSON save");

    // Write type and ID
    dest.Set("type", GetTypeName());
    dest.Set("id", (int) id_);

    JSONArray attributesArray;
    attributesArray.Reserve(xmlAttributeInfos_.Size());
    for (unsigned i = 0; i < xmlAttributeInfos_.Size(); ++i)
    {
        JSONValue attrVal;
        attrVal.Set("name", xmlAttributeInfos_[i].name_);
        attrVal.Set("value", xmlAttributes_[i]);
        attributesArray.Push(attrVal);
    }
    dest.Set("attributes", attributesArray);

    return true;
}