Skip to content

Reading ordered_json from file causes compile error #2331

Description

@jin-clova

What is the issue you have?

Code below is causing compilation error.

    std::ifstream i(path);
    ordered_json j;
    i >> j;

(20462, 53) No viable conversion from 'typename basic_json<nlohmann::ordered_map, std::vector, basic_string, bool, long long, unsigned long long, double, std::allocator, adl_serializer, vector<unsigned char, allocator > >::object_t::iterator' (aka '__wrap_iter<std::__1::pair<const std::__1::basic_string, nlohmann::basic_json<nlohmann::ordered_map, std::vector, std::__1::basic_string, bool, long long, unsigned long long, double, std::allocator, adl_serializer, std::__1::vector<unsigned char, std::__1::allocator > > > *>') to 'const std::__1::basic_string'

Please describe the steps to reproduce the issue.

  1. Write the code above.
  2. Try build
  3. Boom!

Can you provide a small but working code example?

It's not working, but see above for the code.

What is the expected behavior?

Successfully built, and read the json file.

And what is the actual behavior instead?

Compile error

Which compiler and operating system are you using?

  • Compiler: xcode
  • Operating system: mac

Which version of the library did you use?

  • latest release version 3.9.0
  • other release - please state the version: ___
  • the develop branch

If you experience a compilation error: can you compile and run the unit tests?

  • yes
  • no - please copy/paste the error message below

I can compile this project and pass all unit tests, but I don't think the tests cover this case.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions