简体   繁体   中英

ArangoDB Java Driver Forwardslash in _id is escaped

When querying ArangoDB with an AQL query by means of the Java Driver, the forward slash in the _id property is escaped.

The result is:

{"_id":"sed\/CLI_ELE_ALL_400_01.324fd0e4-cf8a-4e39-9889-d1c50ab3594c","_key":"...

but I would like this:

{"_id":"sed/CLI_ELE_ALL_400_01.324fd0e4-cf8a-4e39-9889-d1c50ab3594c","_key":"...

code snippet:

  String query = "for node in nodes return node"

  try {

        ArangoCursor<String> cursor = driver.query(query, null, null, String.class);

        if (cursor.hasNext()) {
            data = cursor.next();
            System.out.println(data));
        }

    } catch (ArangoDBException ex) {}

    return data;

Is there some way to circumvent this without needing to regex replace everything??

You set the parameter type in your query() call to String , this leads the java-driver to parse the result into the Json format. In Json it is correct that / and other characters are escaped. Every Json parser should be able to deal with it.

The java-driver already supports parsing the result into a POJO, Map<String, Object> or into the utility class BaseDocument without the detour over Json. You can find some examples for this here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM