glideapps / glideapps/quicktype
PokedexSchema.hpp is undefined, multisource example - c++ cpp
- Dominant language
- TypeScript
- Stars
- 13.9k
- Forks
- 1.2k
- Avg merge
- 8h 53m
- Merged PRs (30d)
- 369
Description
I am trying to follow the example to parse a PokemonSchema serialized string.
I am using the instructions in `PokemonSchema.hpp`
```
// To parse this JSON data, first install
//
// json.hpp https://github.com/nlohmann/json
//
// Then include this file, and then do
//
// PokedexSchema.hpp data = nlohmann::json::parse(jsonString);
```
And using this code, I get the error identifier "PokemonSchema" is undefined.
```
#include "stdafx.h"
#include
#include
#include
#include "PokedexSchema C++ (quicktype)/PokedexSchema.hpp"
int main(int argc, char* argv) {
std::string jsonString = "{}";
PokedexSchema.hpp data = nlohmann::json::parse(jsonString);
}
```
So I tried to parse it directly into the object, as would be done in the single source solution:
```
// To parse this JSON data, first install
//
// json.hpp https://github.com/nlohmann/json
//
// Then include this file, and then do
//
// PokedexSchema data = nlohmann::json::parse(jsonString);
```
```
#include "stdafx.h"
#include
#include
#include
#include "PokedexSchema C++ (quicktype)/PokedexSchema.hpp"
int main(int argc, char* argv) {
std::string jsonString = "{}";
quicktype::PokedexSchema data = nlohmann::json::parse(jsonString);
}
```
I receive the following error at compile-time.
`E0312 no suitable user-defined conversion from "nlohmann::basic_json" to "quicktype::PokedexSchema" exists`
So what is the correct way to parse a jsonString into a Multi-source solution custom object in cpp?
Contributor guide
Assessment
This issue has not been assessed yet.