MCPcopy Create free account
hub / github.com/OSGeo/gdal / Load

Method Load

port/cpl_json.cpp:196–217  ·  view source on GitHub ↗

* Load json document from file by provided path * @param osPath Path to json file. * @return true on success. If error occurred it can be received using * CPLGetLastErrorMsg method. * */

Source from the content-addressed store, hash-verified

194 *
195 */
196bool CPLJSONDocument::Load(const std::string &osPath)
197{
198 GByte *pabyOut = nullptr;
199 vsi_l_offset nSize = 0;
200
201 GIntBig nMaxSize = 0;
202 if (CPLParseMemorySize(CPLGetConfigOption("CPL_JSON_MAX_SIZE", "100MB"),
203 &nMaxSize, nullptr) != CE_None ||
204 nMaxSize <= 0)
205 return false;
206
207 if (!VSIIngestFile(nullptr, osPath.c_str(), &pabyOut, &nSize, nMaxSize))
208 {
209 CPLError(CE_Failure, CPLE_FileIO, "Load json file %s failed",
210 osPath.c_str());
211 return false;
212 }
213
214 bool bResult = LoadMemory(pabyOut, static_cast<int>(nSize));
215 VSIFree(pabyOut);
216 return bResult;
217}
218
219/**
220 * Load json document from memory buffer.

Callers 2

GetConfigurationMethod · 0.45

Calls 5

CPLParseMemorySizeFunction · 0.85
VSIIngestFileFunction · 0.85
CPLErrorFunction · 0.85
VSIFreeFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected