Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where is json::parse now? #1702

Closed
pmahend1 opened this issue Aug 9, 2019 · 22 comments
Closed

Where is json::parse now? #1702

pmahend1 opened this issue Aug 9, 2019 · 22 comments
Labels
kind: question platform: visual studio related to MSVC solution: invalid the issue is not related to the library

Comments

@pmahend1
Copy link

pmahend1 commented Aug 9, 2019

  • Describe what you want to achieve.
    Trying to parse a string into json and then extract values and create object
    image

class "nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t, uint64_t, double, std::allocator, nlohmann::adl_serializer>" has no member "parse"

Getting error class "nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t, uint64_t, double, std::allocator, nlohmann::adl_serializer>" has no member "parse"

  • Describe what you tried.
#include <iomanip>
#include <fstream>
#include <sstream>

#include <iostream>
#include <nlohmann/json.hpp>

using json = nlohmann::json;
using namespace std;
.
.
.
int main(){
	auto j3 = json::parse("{ \"happy\": true, \"pi\": 3.141 }");
}
  • Describe which system (OS, compiler) you are using.
    Windows 10
  • Describe which version of the library you are using (release version, develop branch).

VCPKG

nlohmann-json:x64-windows                          3.7.0            JSON for Modern C++
nlohmann-json:x64-windows-static                   3.7.0            JSON for Modern C++
nlohmann-json:x86-windows                          3.7.0            JSON for Modern C++
nlohmann-json:x86-windows-static                   3.7.0            JSON for Modern C++
@nlohmann
Copy link
Owner

nlohmann commented Aug 9, 2019

In order to asses your issue, we need the following information:

  • What is the issue you have?

  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?

  • What is the expected behavior?

  • And what is the actual behavior instead?

  • Which compiler and operating system are you using? Is it a supported compiler?

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

@nlohmann nlohmann added the state: needs more info the author of the issue needs to provide more details label Aug 9, 2019
@pmahend1
Copy link
Author

pmahend1 commented Aug 9, 2019

  • Getting error parse method not found
  • Installed from vcpkg : .\vcpkg.exe insatll nlohmann-json:x64-windows nlohmann-json:x64-windows-static nlohmann-json:x86-windows nlohmann-json:x86-windows-static version3.7
  • Expected behavior : should not get error parse method not found
  • Compiler Visual studio 16.2 : 14.2 (seems supported)
  • will run tests and get back to you

@nlohmann
Copy link
Owner

nlohmann commented Aug 9, 2019

  • What is the exact error message?
  • Can you use the JSON library apart from the parse function? For instance, can you compile a program that does nothing but json j;?

@pmahend1
Copy link
Author

pmahend1 commented Aug 9, 2019

  • Exact error

nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t, uint64_t, double, std::allocator, nlohmann::adl_serializer>" has no member "parse

  • Yes, the below code is compiling and running fine.
#include <iostream>

#include "nlohmann/json.hpp"
using json = nlohmann::json;
using namespace std;
int main()
{
	json j;
	return 0;
}

@nlohmann
Copy link
Owner

nlohmann commented Aug 9, 2019

Strange...

Can you please try:

std::string s = "{ \"happy\": true, \"pi\": 3.141 }";
json j = json::parse(s);

?

@erap320
Copy link

erap320 commented Aug 9, 2019

I have the same exact behaviour in Visual Studio 2019, using the single include file.
The strangest thing is that everything seems to work correctly when I compile and run the program. Intellisense just refuses to find json::parse() while editing the code and doesn't accept it even after building finished succesfully, as I said before.

@nlohmann
Copy link
Owner

nlohmann commented Aug 9, 2019

Oh, @pmahend1 - does the code compile or is it just an IntelliSense error?

@pmahend1
Copy link
Author

pmahend1 commented Aug 9, 2019

Strange...

Can you please try:

std::string s = "{ \"happy\": true, \"pi\": 3.141 }";
json j = json::parse(s);

?

This fails :Compilation error

Running tests --> I am getting Test not available without configuration. (Missing "-C <config>"?) error i.ePS C:\workspace\json\build> ctest --output-on-failure`

@nlohmann
Copy link
Owner

nlohmann commented Aug 9, 2019

What is the exact compilation error message?

@pmahend1
Copy link
Author

pmahend1 commented Aug 9, 2019

Please ignore. This is intellisense issue. Seems something went wrong with latest visual studio 16.2.1
If I filter out Intellisense errors , this compiles and runs as well.

@pmahend1 pmahend1 closed this as completed Aug 9, 2019
@nlohmann nlohmann added platform: visual studio related to MSVC solution: invalid the issue is not related to the library and removed state: needs more info the author of the issue needs to provide more details labels Aug 9, 2019
@nlohmann
Copy link
Owner

nlohmann commented Aug 9, 2019

Thanks!

@erap320
Copy link

erap320 commented Aug 9, 2019

Please ignore. This is intellisense issue. Seems something went wrong with latest visual studio 16.2.1
If I filter out Intellisense errors , this compiles and runs as well.

So the only solution is to wait for a new build of VS and keep editor errors while developing?

@nlohmann
Copy link
Owner

nlohmann commented Aug 9, 2019

I would not know any other way.

@bhardwajs
Copy link

@erap320 - You might also want to report to Visual Studio at https://developercommunity.visualstudio.com/spaces/62/index.html.

@pmahend1
Copy link
Author

pmahend1 commented Aug 9, 2019

I have reported on developer community

@d-tatianin
Copy link

Yup, still getting this error on visual studio 2019 16.2.3.

@nlohmann
Copy link
Owner

Maybe fixed with #1799.

@xarthurx
Copy link

@nlohmann Not really.
I updated to the newest 3.7.3, still got this error. Though it doesn't affect the compilation, but it is still there FYI.

@stefgodin
Copy link

Turns out the error will be fixed in VS 2019 16.4.

Right now it's only available as preview version. You can download and install it from here. Although I wouldn't use it for serious development.

If you need proof:
image
On the left is 16.3 and on the right is 16.4.

So to problem is really caused by VS and not the library itself.

The problem was previously reported on the developper comunity

@nlohmann
Copy link
Owner

@Stefmachine Thanks a lot for checking!

@Niek-Okido
Copy link

currently using 16.6.3 version of visual studio, and i get the same issue.
i can paste wat for error i get etc. but it is exact the same

gr

@nlohmann
Copy link
Owner

nlohmann commented Jul 2, 2020

See #1702 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question platform: visual studio related to MSVC solution: invalid the issue is not related to the library
Projects
None yet
Development

No branches or pull requests

8 participants