diff --git a/inst/include/jsonify/from_json/from_json.hpp b/inst/include/jsonify/from_json/from_json.hpp index e9cc6b9..bb0df08 100644 --- a/inst/include/jsonify/from_json/from_json.hpp +++ b/inst/include/jsonify/from_json/from_json.hpp @@ -67,6 +67,7 @@ namespace from_json { return out; } + // const rapidjson::Value& template< typename T > inline SEXP parse_json( const T& json, @@ -90,14 +91,14 @@ namespace from_json { return Rcpp::wrap< bool >( json ); } case rapidjson::kStringType: { - return Rcpp::wrap( std::string( json.GetString() ) ); + return Rcpp::wrap< const char* >( json ); } // numeric case rapidjson::kNumberType: { if( json.IsDouble() ) { - return Rcpp::wrap< double >( json.GetDouble() ); + return Rcpp::wrap< double >( json ); } else { - return Rcpp::wrap< int >( json.GetInt() ); + return Rcpp::wrap< int >( json ); } } case rapidjson::kObjectType: { diff --git a/inst/include/jsonify/from_json/simplify/simplify.hpp b/inst/include/jsonify/from_json/simplify/simplify.hpp index 641c962..ca2b7b2 100644 --- a/inst/include/jsonify/from_json/simplify/simplify.hpp +++ b/inst/include/jsonify/from_json/simplify/simplify.hpp @@ -90,14 +90,14 @@ namespace from_json { // bool case rapidjson::kFalseType: {} case rapidjson::kTrueType: { - out[i] = child.GetBool(); + out[i] = Rcpp::wrap< bool >( child ); update_rtype< LGLSXP >( r_type ); break; } // string case rapidjson::kStringType: { - out[i] = Rcpp::String( child.GetString() ); + out[i] = Rcpp::wrap< const char * >( child ); update_rtype< STRSXP >( r_type ); break; } @@ -106,11 +106,11 @@ namespace from_json { case rapidjson::kNumberType: { if( child.IsDouble() ) { // double - out[i] = child.GetDouble(); + out[i] = Rcpp::wrap< double >( child ); update_rtype< REALSXP >( r_type ); } else { // int - out[i] = child.GetInt(); + out[i] = Rcpp::wrap< int >( child ); update_rtype< INTSXP >( r_type ); } break; diff --git a/inst/include/jsonify/jsonify_types.hpp b/inst/include/jsonify/jsonify_types.hpp index fb92577..8bf0077 100644 --- a/inst/include/jsonify/jsonify_types.hpp +++ b/inst/include/jsonify/jsonify_types.hpp @@ -7,29 +7,23 @@ namespace Rcpp { -template< typename T > SEXP wrap( const rapidjson::Value& obj ); + // template<> SEXP wrap( std::basic_string& obj ); + template< typename T > SEXP wrap( const rapidjson::Value& obj ); namespace traits { } // traits } // Rcpp - - - #include - - namespace Rcpp { -template< typename T > -SEXP wrap( const rapidjson::Value& obj) { - - const int RTYPE = Rcpp::traits::r_sexptype_traits< T >::rtype; - - return Rcpp::wrap< RTYPE >( obj.Get< T >() ); -} + template< typename T > + SEXP wrap( const rapidjson::Value& obj) { + auto b = obj.Get< T >(); + return Rcpp::wrap( b ); + } namespace traits {