On 01/12/2016 02:52, Serkan Mulayim wrote:
I am using the Lucy C library.
I would like to ask if it is possible to get the HitDocs as Json Strings.
I see that there is a dump method "LUCY_Doc_Dump" in Doc.c and HitDoc, can
this be used for this. Can you elaborate on what "dump" does? There is
also S_to_json in json.c which expects a dump object to create a
JsonString. Can I use them. If so how?
Also what do serialize functions do in Doc classes. Can I use them for
this purpose?
Dump/Load and Serialize/Deserialize are private methods that are only used
internally. The C library doesn't even implement Dump/Load. Serialization is
used for Lucy's on-disk format and unlikely to be useful for anything else.
Lucy has an internal JSON encoder/decoder in Lucy::Util::Json. This is also a
private API and only supports a subset of JSON. But you should be able to
convert a Doc or HitDoc into a JSON string with the C library using
Doc_Get_Fields:
#include <Lucy/Util/Json.h>
// Get_Fields returns a (non-incremented) Hash for the C bindings.
Obj *hash = (Obj*)HitDoc_Get_Fields(doc);
String *json = Json_to_json(hash);
The usual caveats for private APIs apply. They aren't supported officially and
can change without notice. You can find some documentation for private APIs in
the .cfh files.
Nick