1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
/*
FALCON - The Falcon Programming Language.
FILE: json_srv.cpp
JSON Service module -- an interface to access the JSON module.
-------------------------------------------------------------------
Author: Giancarlo Niccolai
Begin: Sun, 27 Sep 2009 20:58:05 +0200
-------------------------------------------------------------------
(C) Copyright 2009: the FALCON developers (see list in AUTHORS file)
See LICENSE file for licensing details.
*/
#include <falcon/srv/json_srv.h>
#include <falcon/string.h>
#include <falcon/stream.h>
#include <falcon/stringstream.h>
#include <falcon/rosstream.h>
#include "json_mod.h"
namespace Falcon
{
JSONService::JSONService():
Service( JSONSERVICE_NAME )
{}
bool JSONService::encode( const Item& itm, String& tgt, bool bPretty, bool bReadale )
{
JSON js( bPretty, bReadale );
StringStream ss;
if( ! js.encode( itm, &ss ) )
return false;
ss.closeToString(tgt);
return true;
}
bool JSONService::encode( const Item& itm, Stream* tgt, bool bPretty, bool bReadale )
{
JSON js( bPretty, bReadale );
return js.encode( itm, tgt );
}
bool JSONService::decode( const String& str, Item& tgt )
{
JSON js;
ROStringStream ss(str);
return js.decode( tgt, &ss );
}
bool JSONService::decode( Stream* source, Item& tgt )
{
JSON js;
return js.decode( tgt, source );
}
}
/* end of json_srv.cpp */
|