* 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. * */
| 194 | * |
| 195 | */ |
| 196 | bool 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. |
no test coverage detected