void ProtoLoadEntity(const FilePath& fname) { std::shared_ptr<EntityCreated> data = std::make_shared<EntityCreated>(); std::string json_string = LoadJSON(fname); google::protobuf::util::JsonStringToMessage(json_string, &data->entity); data->entity_id = data->entity.id(); EventSystem<EntityCreated>::Get()->Emit(data); }
void Localization::LoadJSONFile(const QString& name) { ResourceCache* cache = context_->resourceCache(); JSONFile* jsonFile = cache->GetResource<JSONFile>(name); if (jsonFile) LoadJSON(jsonFile->GetRoot()); }
void Localization::LoadJSONFile(const String& name) { ResourceCache* cache = GetSubsystem<ResourceCache>(); JSONFile* jsonFile = cache->GetResource<JSONFile>(name); if (jsonFile) LoadJSON(jsonFile->GetRoot()); }
void ColoursAndFontsManager::OnLexerFilesLoaded(const std::vector<wxXmlDocument*>& userLexers) { // User lexers wxFileName fnUserLexers(clStandardPaths::Get().GetUserDataDir(), "lexers.json"); fnUserLexers.AppendDir("lexers"); // Default installation lexers #ifdef USE_POSIX_LAYOUT wxFileName defaultLexersFileName(clStandardPaths::Get().GetDataDir() + wxT(INSTALL_DIR), ""); #else wxFileName defaultLexersFileName(clStandardPaths::Get().GetDataDir(), ""); #endif defaultLexersFileName.AppendDir("lexers"); defaultLexersFileName.SetFullName("lexers.json"); wxString str_defaultLexersFileName = defaultLexersFileName.GetFullPath(); wxUnusedVar(str_defaultLexersFileName); m_allLexers.clear(); m_lexersMap.clear(); if(!fnUserLexers.FileExists()) { // Load default settings LoadJSON(defaultLexersFileName); // Use old XML files LoadOldXmls(userLexers); // Call save to create an initial user settings Save(); } else { // Load the user settings LoadJSON(fnUserLexers); } // Update lexers versions clConfig::Get().Write(LEXERS_VERSION_STRING, LEXERS_VERSION); }
int Playlist::LoadJSONIntoPlaylist(std::vector<PlaylistEntryBase*> &playlistPart, const Json::Value &entries) { PlaylistEntryBase *plEntry = NULL; for (int c = 0; c < entries.size(); c++) { #if 1 // Long-term handle sub-playlists on-demand instead of at load time if (entries[c]["type"].asString() == "playlist") { m_subPlaylistDepth++; if (m_subPlaylistDepth < 3) { Json::Value subPlaylist = LoadJSON(entries[c]["name"].asString().c_str()); if (subPlaylist.isMember("leadIn")) LoadJSONIntoPlaylist(playlistPart, subPlaylist["leadIn"]); if (subPlaylist.isMember("mainPlaylist")) LoadJSONIntoPlaylist(playlistPart, subPlaylist["mainPlaylist"]); if (subPlaylist.isMember("leadOut")) LoadJSONIntoPlaylist(playlistPart, subPlaylist["leadOut"]); } else { LogErr(VB_PLAYLIST, "Error, sub-playlist depth exceeded 3 trying to include '%s'\n", entries[c]["playlistName"].asString().c_str()); } m_subPlaylistDepth--; } else #endif { plEntry = LoadPlaylistEntry(entries[c]); if (plEntry) playlistPart.push_back(plEntry); } } return 1; }
int Playlist::ReloadPlaylist(void) { LogDebug(VB_PLAYLIST, "Playlist::ReloadPlaylist()\n"); std::unique_lock<std::recursive_mutex> lck (m_playlistMutex); std::string currentSectionStr = m_currentSectionStr; int repeat = m_repeat; Json::Value root = LoadJSON(m_filename.c_str()); if (!Load(root)) return 0; m_currentSectionStr = currentSectionStr; m_repeat = repeat; GetConfigStr(); return 1; }
bool clutl::BuildParameterObjectCache_JSON(clutl::ParameterObjectCache& poc, const clcpp::Function* function, clutl::ReadBuffer& parameter_source) { // Reuse the incoming cache poc.Init(function); // A local cache of all function parameters in their sorted order const clcpp::Field* sorted_fields[ParameterData::MAX_NB_FIELDS]; // Sort each parameter into its call order unsigned int nb_fields = function->parameters.size; for (unsigned int i = 0; i < nb_fields; i++) { const clcpp::Field* field = function->parameters[i]; clcpp::internal::Assert(field->offset < ParameterData::MAX_NB_FIELDS); sorted_fields[field->offset] = field; } // Check for parameter opening list JSONContext ctx(parameter_source); JSONToken t = LexerNextToken(ctx); if (t.type != JSON_TOKEN_LBRACKET) return false; // Allocate parameters for each field for (unsigned i = 0; i < nb_fields; i++) { const clcpp::Field* field = sorted_fields[i]; void* param_object = poc.AllocParameter(field); // Parse the JSON parameter and move onto the next one JSONError error = LoadJSON(ctx, param_object, field); if (error.code != clutl::JSONError::NONE) return false; } // TODO: What about patching up pointers? return true; }
int Playlist::Load(const char *filename) { LogDebug(VB_PLAYLIST, "Playlist::Load(%s)\n", filename); if (mqtt) mqtt->Publish("playlist/name/status", filename); m_filename = getPlaylistDirectory(); m_filename += "/"; m_filename += filename; m_filename += ".json"; std::unique_lock<std::recursive_mutex> lck (m_playlistMutex); Json::Value root = LoadJSON(m_filename.c_str()); int res = Load(root); GetConfigStr(); return res; }
void MainWindow::on_actionOpen_JSON_File_triggered() { QString filePath = QFileDialog::getOpenFileName(this, tr("Open JSON File"), "", tr("JSON Files (*.json);;All Files (*.*)")); LoadJSON(filePath); }