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

[json.hpp] from releases doesnt work #2897

Closed
2 of 5 tasks
nonunknown opened this issue Jul 28, 2021 · 2 comments
Closed
2 of 5 tasks

[json.hpp] from releases doesnt work #2897

nonunknown opened this issue Jul 28, 2021 · 2 comments

Comments

@nonunknown
Copy link

nonunknown commented Jul 28, 2021

What is the issue you have?

Everytime I run the program it throws a parse error (json file is valid)

Please describe the steps to reproduce the issue.

  1. Download the <json.hpp>
    2.Include it
  2. Do some coding and compile

Can you provide a small but working code example?

#ifndef EXT_H
#define EXT_H

#include <json.hpp>
#include <fstream>
#include <iostream>

using namespace std;
using namespace nlohmann;

void LoadExtension()
{
	ifstream file("../test.json");
	json data;
	file >> data;


	cout << data << endl;
	//test
}




#endif // !EXT_H

What is the expected behavior?

Show the entire json file

And what is the actual behavior instead?

Error message:

terminate called after throwing an instance of 'nlohmann::detail::parse_error'
  what():  [json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal
make: *** [Makefile:17: run] Aborted (core dumped)

Which compiler and operating system are you using?

Manjaro linux 21 with g++

This is the MakeFile:

CXX		  := g++
CXX_FLAGS := -Wall -Wextra -std=c++11 -ggdb -Werror -O3

BIN		:= bin
SRC		:= src
INCLUDE	:= include
LIB		:= lib

LIBRARIES	:=
EXECUTABLE	:= main


all: $(BIN)/$(EXECUTABLE)

run: clean all
	clear
	./$(BIN)/$(EXECUTABLE)

$(BIN)/$(EXECUTABLE): $(SRC)/*.cpp
	$(CXX) $(CXX_FLAGS) -I$(INCLUDE) -L$(LIB) $^ -o $@ $(LIBRARIES)

clean:
	-rm $(BIN)/*

build:
	clean all
	$(BIN)/$(EXECUTABLE): $(SRC)/*.cpp
	$(CXX) $(CXX_FLAGS) -I$(INCLUDE) -L$(LIB) $^ -o $@ $(LIBRARIES)

Which version of the library did you use?

  • latest release version 3.9.1
  • 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
@nlohmann
Copy link
Owner

nlohmann commented Jul 29, 2021

Please make sure the file was actually opened. In particular, please check if you execute the binary in a path where the relative path in the source makes sense.

@nonunknown
Copy link
Author

worked flawless! thanks dude!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants