Skip to content

[json.hpp] from releases doesnt work #2897

@nonunknown

Description

@nonunknown

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions