peerplays-fc/include/fc/json.hpp
Daniel Larimer 3d56a96d4e major updates to stream,reflect,value,and json
- removed polymorphic reflection, made static_reflect default because
  there are cases such as deserializing an array that you need more
  information than the runtime reflection can provide such as the
  ability to resize arrays and know the array content type.

- refactored iostream, sstream, fstream to be much simpler, fewer
  indirections, and fixed getline.

- json parsing works using code from mace.
- value is reimplemented based upon mace::rpc::value and no longer uses
  the runtime reflection that was removed.

- moved the typename utility to its own header
2012-10-21 02:28:59 -04:00

48 lines
1.1 KiB
C++

#pragma once
#include <fc/string.hpp>
#include <fc/value.hpp>
#include <fc/value_cast.hpp>
#include <fc/vector_fwd.hpp>
namespace fc {
class istream;
class ostream;
class path;
namespace json {
string to_string( const value& o );
value from_string( const string& s );
value from_string( const char* s, const char* e );
value from_string( const fc::vector<char>& v );
string escape_string( const string& );
string unescape_string( const string& );
void write( ostream& out, const value& val );
template<typename T>
void write( ostream& out, const T& val ) {
write( out, value(val) );
}
template<typename T>
string to_string( const T& o ) {
return json::to_string(value(o));
}
template<typename T>
T from_string( const string& s ) {
return value_cast<T>( from_string(s) );
}
value from_file( const fc::path& s );
template<typename T>
T from_file( const fc::path& s ) {
return value_cast<T>( fc::json::from_file(s) );
}
} // namespace json
} // fc