Json: basic_json has no member "parse"

Created on 28 Aug 2019  路  6Comments  路  Source: nlohmann/json

  • What is the issue you have?

Copied the json.hpp file (v3.7.0) from release into my C++ project, the IDE (VS2019) instantly reports problems with 2 issues:

class "nlohmann:basic_json" has no member "parse".

https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp#L22516

And one error I am a little bit less concerned about because I don't need it to parse a json:

class "nlohmann:basic_json" has no member "swap".

https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp#L22495

  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?
  1. Create a new C++ Dynamic Link Library Project in VS2019
  2. Add json.hpp
  3. See errors

Visual Studio 2019 (v142)
Also tried Visual Studio 2017 (v141) but that even gave me more issues.

  • Did you use a released version of the library or the version from the develop branch?

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

FYI: I am a C++ noob

visual studio invalid

Most helpful comment

For anyone still running into this, there's a workaround available. Add the following flag to 'Additional Options' under your project's Configuration Properties -> C/C++ -> Command Line options.

Zc:__cplusplus

Workaround

All 6 comments

It seems just an error from Visual Studio IntelliSense, not an actual compiler.
Maybe a bug of IntelliSense?

Visual Studio 2019 (16.2.5) suffers from the same IntelliSense bug, hoping for a fix soon.

As the issue is not related to the library, but rather IntelliSense, I'm closing the issue.

For anyone still running into this, there's a workaround available. Add the following flag to 'Additional Options' under your project's Configuration Properties -> C/C++ -> Command Line options.

Zc:__cplusplus

Workaround

For anyone still running into this, there's a workaround available. Add the following flag to 'Additional Options' under your project's Configuration Properties -> C/C++ -> Command Line options.

I'm absolutely floored by the fact that this simple compiler switch actually makes IntelliSense play nicely with complex template code. It's much more pleasant than what I was doing before (stubbing the entire API inside of #ifdef __INTELLISENSE__ blocks).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

koemeet picture koemeet  路  4Comments

sqwunkly picture sqwunkly  路  3Comments

asmaloney picture asmaloney  路  4Comments

zhishupp picture zhishupp  路  4Comments

alienzj picture alienzj  路  4Comments