How to store `"` and `CRLF` in dgraph?

mutation

(Cbwleft) #1

The input language is triples in the W3C standard RDF N-Quad format.

and

Literals may not contain the characters " , LF , or CR . In addition ’ \ ’ (U+005C) may not appear in any quoted literal except as part of an escape sequence.

how can I store these characters?


(Michel Conrado) #2

Dgraph does not strictly use the W3C standard. Use something similar with this standard. However, if you give an example of this literal it would help to understand how.


(Cbwleft) #3

how to escape a line break, or a quotation mark? these mutations below are illegal.

{
  set{
    <0x58b> <description> "test
    " .
  }
}
{
  set{
    <0x58b> <description> "test"" .
  }
}

(Michel Conrado) #4

You can use any lib or site like this to test out https://www.freeformatter.com/json-escape.html#ad-output
This is the right way:

{
  set{
    <0x58b> <description> "test\r\n"" .
  }
}

Cheers.


(Cbwleft) #5

My bad, that works fine in ratel.

My problem is how to escape these string in java. StringEscapeUtils.escapeJava solve the problem. thanks anyway.:grin: