Java Marklogic eval response processing providing JSON documents

I have an MarkLogic XQuery eval call that returns lists of strings. I use the code below to process the results. I have another call that returns a list of Json Documents, but I don't see how to get EvalResult to provide me with a JsonDocument document. How to change the below code to handle Json Documents?

   public static ArrayList<String> getStringList(DatabaseClient client, String query)
   {
      ArrayList<String> strings = new ArrayList<String>();
      ServerEvaluationCall eval = client.newServerEval();
      EvalResultIterator eri = eval.xquery(query).eval();
      while (eri.hasNext())
      {
         EvalResult er = eri.next();
         String s = er.getString();
         strings.add(s);
      }
      return strings;
   }
+4
source share
1 answer

-, , eval , . , , . , , , eval, : ResourceExtension JavascriptResourceExtension.

, :

     String s = er.getString();

:

     JacksonHandle handle = er.get(new JacksonHandle());
     JsonNode json = handle.get();

:

     JsonNode json = er.getAs(JsonNode.class);

. myArray myObject EvalTest.evalAndInvokeXQuery (, , runAndTestXQuery) evaltest.xqy.

Jackson , JSON , . io . . JacksonHandleExample, JacksonHandleTest, JacksonStreamTest JacksonDatabindTest.

+2

Source: https://habr.com/ru/post/1671922/


All Articles