Esempio n. 1
0
SamiBoolQuery::SamiBoolQuery(String* json) {
    init();
    String str(json->GetPointer());
    int length = str.GetLength();

    ByteBuffer buffer;
    buffer.Construct(length);

    for (int i = 0; i < length; ++i) {
       byte b = str[i];
       buffer.SetByte(b);
    }

    IJsonValue* pJson = JsonParser::ParseN(buffer);
    fromJsonObject(pJson);
    if (pJson->GetType() == JSON_TYPE_OBJECT) {
       JsonObject* pObject = static_cast< JsonObject* >(pJson);
       pObject->RemoveAll(true);
    }
    else if (pJson->GetType() == JSON_TYPE_ARRAY) {
       JsonArray* pArray = static_cast< JsonArray* >(pJson);
       pArray->RemoveAll(true);
    }
    delete pJson;
}
Esempio n. 2
0
void AnimationToJson::fromJsonObject(KeyFrame &keyFrame, const QJsonObject &object, const QString &fileName)
{
    keyFrame.setFileName(QFileInfo(fileName).dir().absolutePath() + "/" + object.find("fileName").value().toString());
    keyFrame.setOffset(pointFromJsonObject(object.find("offset").value().toObject()));
    keyFrame.setRect(rectFromJsonObject(object.find("rect").value().toObject()));

    QJsonObject customPropertiesObject = object.find("customProperties").value().toObject();
//    qDebug() << customPropertiesObject;
    for (auto it = customPropertiesObject.begin(); it != customPropertiesObject.end(); ++it) {
        keyFrame.setCustomProperty(it.key(), it.value().toDouble());
    }
//    for (const auto &value : customPropertiesObject) {
//        value.
//        qDebug() << value;
//        for (auto it = value.begin(); it != value.end(); ++it) {
//            keyFrame.setCustomProperty(it.key(), it.value().toDouble());
//        }
//    }

    for (const QJsonValue &value : object.find("hitBoxes").value().toArray()) {
        auto hitBox = new HitBox();
        fromJsonObject(*hitBox, value.toObject());
        keyFrame.insertHitBox(keyFrame.hitBoxes().count(), hitBox);
    }
}
SamiShowcaseDatatypePrimitives*
SamiShowcaseDatatypePrimitives::fromJson(String* json) {
    this->cleanup();
    String str(json->GetPointer());
    int length = str.GetLength();

    ByteBuffer buffer;
    buffer.Construct(length);

    for (int i = 0; i < length; ++i) {
       byte b = str[i];
       buffer.SetByte(b);
    }

    IJsonValue* pJson = JsonParser::ParseN(buffer);
    fromJsonObject(pJson);
    if (pJson->GetType() == JSON_TYPE_OBJECT) {
       JsonObject* pObject = static_cast< JsonObject* >(pJson);
       pObject->RemoveAll(true);
    }
    else if (pJson->GetType() == JSON_TYPE_ARRAY) {
       JsonArray* pArray = static_cast< JsonArray* >(pJson);
       pArray->RemoveAll(true);
    }
    delete pJson;
    return this;
}
Esempio n. 4
0
void AnimationToJson::fromJsonObject(Animation &animation, const QJsonObject &object, const QString &fileName)
{
    animation.setFrameCount(object.find("frameCount").value().toInt());
    animation.setFps(object.find("fps").value().toInt());
    animation.setOrigin(pointFromJsonObject(object.find("origin").value().toObject()));

    QJsonArray keyFramesArray = object.find("keyFrames").value().toArray();
    for(auto keyFrameValue : keyFramesArray) {
        QJsonObject keyFrameObject = keyFrameValue.toObject();
        int frame = keyFrameObject.find("frame").value().toInt();

        auto keyFrame = new KeyFrame;
        fromJsonObject(*keyFrame, keyFrameObject.find("data").value().toObject(), fileName);
        animation.insertKeyFrame(frame, keyFrame);
    }
}
v8::Handle<v8::Value> QV8JsonWrapper::fromJsonValue(const QJsonValue &value)
{
    if (value.isString())
        return QJSConverter::toString(value.toString());
    else if (value.isDouble())
        return v8::Number::New(value.toDouble());
    else if (value.isBool())
        return value.toBool() ? v8::True() : v8::False();
    else if (value.isArray())
        return fromJsonArray(value.toArray());
    else if (value.isObject())
        return fromJsonObject(value.toObject());
    else if (value.isNull())
        return v8::Null();
    else
        return v8::Undefined();
}
void ApplicationDescription::initializeFromData(const QString &data)
{
    struct json_object* root = json_tokener_parse( data.toUtf8().constData() );
    if( !root || is_error( root ) )
    {
        qWarning() << "Failed to parse application description";
        return;
    }

    fromJsonObject(root);

	struct json_object* label = json_object_object_get(root,"useLuneOSStyle");
	if (label && !(is_error(label))) {
		mUseLuneOSStyle = json_object_get_boolean(label);
	}

        label = json_object_object_get(root,"useWebEngine");
        if (label && !(is_error(label))) {
                mUseWebEngine = json_object_get_boolean(label);
        }

    if(root && !is_error(root))
        json_object_put(root);
}
Esempio n. 7
0
void AnimationToJson::fromJson(Animation &animation, const QJsonDocument &json, const QString &fileName)
{
    fromJsonObject(animation, json.object(), fileName);
}
void ReadabilityArticle::onResponseReceived(QJsonObject response)
{
    fromJsonObject(m_api->parseArticleResponse(response));
}