From e010a35743a11bd7ed02de41e4edd5c8bbdb19ca Mon Sep 17 00:00:00 2001 From: David Date: Thu, 28 May 2020 20:50:28 +1000 Subject: [PATCH] not right #69 --- inst/include/jsonify/from_json/from_json.hpp | 3 +- inst/include/jsonify/jsonify.hpp | 39 +++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/inst/include/jsonify/from_json/from_json.hpp b/inst/include/jsonify/from_json/from_json.hpp index e36b9de..363fb99 100644 --- a/inst/include/jsonify/from_json/from_json.hpp +++ b/inst/include/jsonify/from_json/from_json.hpp @@ -83,7 +83,8 @@ namespace from_json { } case rapidjson::kFalseType: {} case rapidjson::kTrueType: { - return Rcpp::wrap< bool >( json.GetBool() ); + //return Rcpp::wrap< bool >( json.GetBool() ); + return Rcpp::wrap< bool >( json ); } case rapidjson::kStringType: { return Rcpp::wrap( std::string( json.GetString() ) ); diff --git a/inst/include/jsonify/jsonify.hpp b/inst/include/jsonify/jsonify.hpp index 0b742a4..b5e9e3b 100644 --- a/inst/include/jsonify/jsonify.hpp +++ b/inst/include/jsonify/jsonify.hpp @@ -1,9 +1,46 @@ #ifndef R_JSONIFY_H #define R_JSONIFY_H -#include #include "rapidjson/document.h" +#include + +namespace Rcpp { + + template< typename T > SEXP wrap( const rapidjson::Value::ValueType& obj ); + +namespace traits { + +} // traits +} // Rcpp + + + + +#include + + + +namespace Rcpp { + + template< typename T > + SEXP wrap( const rapidjson::Value::ValueType& obj) { + const int RTYPE = Rcpp::traits::r_sexptype_traits< T >::rtype; + + return Rcpp::wrap< RTYPE >( obj.Get< T >() ); + } + + +namespace traits { + + +} // traits +} // Rcpp + + + + + #include "rapidjson/writer.h" #include "rapidjson/stringbuffer.h" #include "rapidjson/prettywriter.h"