예제 #1
0
std::vector<StarredFile> StarredFile::listFromJSON(const json_t *json, json_error_t *error)
{
    std::vector<StarredFile> files;
    for (size_t i = 0; i < json_array_size(json); i++) {
        StarredFile file = fromJSON(json_array_get(json, i), error);
        files.push_back(file);
    }

    return files;
}
예제 #2
0
std::vector<ServerRepo> ServerRepo::listFromJSON(const json_t *json, json_error_t *error)
{
    std::vector<ServerRepo> repos;
    for (size_t i = 0; i < json_array_size(json); i++) {
        ServerRepo repo = fromJSON(json_array_get(json, i), error);
        repos.push_back(repo);
    }

    return repos;
}
예제 #3
0
std::vector<SeafEvent> SeafEvent::listFromJSON(const json_t *json, json_error_t *error)
{
    std::vector<SeafEvent> events;

    for (size_t i = 0; i < json_array_size(json); i++) {
        SeafEvent event = fromJSON(json_array_get(json, i), error);
        events.push_back(event);
    }

    return events;
}
    TransformMatrix TransformMatrix::fromJSON(std::string json)
    {
        Json::Value root;
        Json::Reader reader;

        if (!reader.parse(json, root)) {
            std::stringstream ss;
            ss << "Unable to decode matrix from: " << json;
            throw ss.str();
        }

        return fromJSON(root);
    }
예제 #5
0
파일: Colours.cpp 프로젝트: OKaluza/LavaVu
Colour::Colour(const std::string& str)
{
  try
  {
    //First attempt to load as JSON string
    json jval = json::parse(str);
    fromJSON(jval);
  }
  catch (std::exception& e)
  {
    //Not valid JSON, assume other string value
    fromString(str);
  }
}
예제 #6
0
OAuth10Credentials OAuth10Credentials::fromFile(const std::string& credentialsFile)
{
    OAuth10Credentials credentials;

    try
    {
        credentials = fromJSON(ofJson::parse(ofBufferFromFile(credentialsFile)));
    }
    catch (const std::exception& exception)
    {
        ofLogError("Credentials::fromFile") << exception.what();
    }

    return credentials;
}
예제 #7
0
파일: project.cpp 프로젝트: Aloshi/bugel
void Project::fromJSON(const QJsonObject& project)
{
    mEventTypes.clear();

    mName = project["name"].toString();
    if (!project["lastOpenedTimeline"].toString().isEmpty())
        mLastOpenedTimeline = QDir(root()).filePath(project["lastOpenedTimeline"].toString());

    const QJsonArray& eventTypes = project["eventTypes"].toArray();
    for (auto it = eventTypes.begin(); it != eventTypes.end(); it++) {
        auto eventType = std::make_shared<EventType>();
        eventType->fromJSON(it->toObject());
        mEventTypes.push_back(eventType);
    }
}
예제 #8
0
LaunchPoint* LaunchPoint::fromFile(ApplicationDescription* appDesc,
								   const std::string& filePath)
{
	char* jsonStr = readFile(filePath.c_str());
	if (!jsonStr)
		return 0;

	// infer the launchpoint ID from the filename
	gchar* fileName = g_path_get_basename(filePath.c_str());

	LaunchPoint* lp = fromJSON(appDesc, jsonStr, fileName);

	delete [] jsonStr;
	g_free(fileName);

	return lp;
}
예제 #9
0
Value Value::fromDynamic(JSContextRef ctx, const folly::dynamic& value) {
// JavaScriptCore's iOS APIs have their own version of this direct conversion.
// In addition, using this requires exposing some of JSC's private APIs,
//  so it's limited to non-apple platforms and to builds that use the custom JSC.
// Otherwise, we use the old way of converting through JSON.
#if USE_FAST_FOLLY_DYNAMIC_CONVERSION
  // Defer GC during the creation of the JSValue, as we don't want
  //  intermediate objects to be collected.
  // We could use JSValueProtect(), but it will make the process much slower.
  JSDeferredGCRef deferGC = JSDeferGarbageCollection(ctx);
  // Set a global lock for the whole process,
  //  instead of re-acquiring the lock for each operation.
  JSLock(ctx);
  JSValueRef jsVal = Value::fromDynamicInner(ctx, value);
  JSUnlock(ctx);
  JSResumeGarbageCollection(ctx, deferGC);
  return Value(ctx, jsVal);
#else
  auto json = folly::toJson(value);
  return fromJSON(String(ctx, json.c_str()));
#endif
}
예제 #10
0
bool File::save()
{
    Client client;

    client.addHeader("Content-Type", contentType_);

    client.setPayload(body_);

    JSON response;

    try
    {
        client.post("files/" + localFileName_);

        response = client.getJSONResponse();
    }
    catch (const exception &e)
    {
        return false;
    }
    fromJSON(response);
    return true;
}
예제 #11
0
File::File(const JSON &obj)
{
    fromJSON(obj);
}
예제 #12
0
 Pointer::Pointer(const JSON &obj)
 {
     fromJSON(obj);
 }
예제 #13
0
파일: Colours.cpp 프로젝트: OKaluza/LavaVu
Colour::Colour(json& jvalue, GLubyte red, GLubyte grn, GLubyte blu, GLubyte alpha) : r(red), g(grn), b(blu), a(alpha)
{
  fromJSON(jvalue);
}