vespa json object changes to string

147 Views Asked by At

i have vespa verion 5.220.14 installed in one server where i have used json (provided by gson lib ) in searcher, while i am deploying the same code in vespa version 5.550 in a diffrentserver it is not working and changing it to string. Attached are the screenshot for same. What could be the possible reason for same, And what should be resolution to make this work. the result in server where vespa 5.550 is installed

the resul of dtaa type in object in server where vespa version is 5.220.14

2

There are 2 best solutions below

1
Arne On

special-handling of org.json in rendering was removed one year ago:

https://github.com/vespa-engine/vespa/pull/16326/files#diff-8cff528a21faf96a6e90b1490adc25ff474ad72e973627ee4e8b9734084ad86f

you should probably wrap your "data" field in a facade that implements the com.yahoo.data.JsonProducer interface:

https://javadoc.io/doc/com.yahoo.vespa/container-search/latest/com/yahoo/data/JsonProducer.html

0
Jon On

Arne is correct, we had to move this due to the license of org.json, sorry for the inconvenience.

To implement Arne's solution, all you need is to replace hit.setField("data", newroot); in your code by

hit.setField("data", (com.yahoo.data.JsonProducer)s -> s.append(resdata));