void osrf_message_set_result_content( osrfMessage*, const char* json_string );
+void osrf_message_set_result( osrfMessage* msg, const jsonObject* obj );
+
void osrfMessageFree( osrfMessage* );
char* osrf_message_to_xml( osrfMessage* );
+jsonObject* osrfMessageToJSON( const osrfMessage* msg );
+
char* osrf_message_serialize(const osrfMessage*);
osrfList* osrfMessageDeserialize( const char* string, osrfList* list );
#include <opensrf/osrf_message.h>
#include "opensrf/osrf_stack.h"
-static jsonObject* osrfMessageToJSON( const osrfMessage* msg );
static osrfMessage* deserialize_one_message( const jsonObject* message );
static char default_locale[17] = "en-US\0\0\0\0\0\0\0\0\0\0\0\0";
/**
- @brief Populate the _result_content membersof an osrfMessage.
+ @brief Populate the _result_content membersof an osrfMessage from a JSON string.
@param msg Pointer to the osrfMessage to be populated.
@param json_string A JSON string encoding a result.
/**
+ @brief Populate the _result_content membersof an osrfMessage from a JSON object.
+ @param msg Pointer to the osrfMessage to be populated.
+ @param obj Pointer to a jsonObject encoding a result.
+
+ Used for a RESULT message to return the results of a remote procedure call.
+*/
+void osrf_message_set_result( osrfMessage* msg, const jsonObject* obj ) {
+ if( msg == NULL || obj == NULL) return;
+ if( msg->_result_content )
+ jsonObjectFree( msg->_result_content );
+
+ msg->_result_content = jsonObjectDecodeClass( obj );
+}
+
+
+/**
@brief Free an osrfMessage and everything it owns.
@param msg Pointer to the osrfMessage to be freed.
*/
The calling code is responsible for freeing the returned jsonObject.
*/
-static jsonObject* osrfMessageToJSON( const osrfMessage* msg ) {
+jsonObject* osrfMessageToJSON( const osrfMessage* msg ) {
jsonObject* json = jsonNewObjectType(JSON_HASH);
jsonObjectSetClass(json, "osrfMessage");