Thank you very much Nick.

I understand that those private APIs can change. Can you explain what the 
format of the "dump" is? When I print it as a string I simply get 
"Lucy::Search::Hits@0x00007f9119703d10". It makes me think that it is doing 
something in memory (I could not find any hooks in disk) to map the hash to the 
Json object. This would be something that I would like to avoid.

The other option is simply generating my own json by escaping the field values.

Thanks again...

On 2016-12-01 06:00 (-0800), Nick Wellnhofer <wellnho...@aevum.de> wrote: 
> 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
> 
> 

Reply via email to