This commit is contained in:
parent
8b15fd52c4
commit
505ed38a50
2 changed files with 12 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "json.h"
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
||||
int JSON::Value::c2hex(int c){
|
||||
if (c >= '0' && c <= '9') return c - '0';
|
||||
|
@ -423,3 +424,13 @@ JSON::Value JSON::fromString(std::string json){
|
|||
std::istringstream is(json);
|
||||
return JSON::Value(is);
|
||||
}
|
||||
|
||||
/// Converts a file to a JSON::Value.
|
||||
JSON::Value JSON::fromFile(std::string filename){
|
||||
std::string Result;
|
||||
std::ifstream File;
|
||||
File.open(filename.c_str());
|
||||
while (File.good()){Result += File.get();}
|
||||
File.close( );
|
||||
return fromString(Result);
|
||||
}
|
||||
|
|
|
@ -69,5 +69,6 @@ namespace JSON{
|
|||
};
|
||||
|
||||
Value fromString(std::string json);
|
||||
Value fromFile(std::string filename);
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue