Note that there are some explanatory texts on larger screens.

plurals
  1. POExtracting a JsonArray from inside a string
    primarykey
    data
    text
    <p>I'm using Delphi XE2 with <code>DBXJSON</code> and I'm having trouble handling a JsonArray contained inside a String. The String I got is this:</p> <pre><code>"[ {DAT_INCL: \"2/3/2012 16:45:9\", NUM_ORDE: 1, NUM_ATND: 734, NUM_ACAO: 2, NUM_RESU: 3}, {DAT_INCL: \"2/3/2012 16:45:10\", NUM_ORDE: 2, NUM_ATND: 734, NUM_ACAO: 4, NUM_RESU: 5}, {DAT_INCL: \"2/3/2012 16:45:10\", NUM_ORDE: 3, NUM_ATND: 734, NUM_ACAO: 8, NUM_RESU: NULL} ]" </code></pre> <p><strong>Goddamn quotation marks.</strong></p> <p>No matter how hard I try, I can never get my hands on this array, no <code>ParseJSONValue</code> and no crazy type juggling could get the array out of this quotation-mark prison.</p> <p>Maybe one of you got the key?</p> <p>EDIT: This string is already the result of a bit of type conversion. In case anyone is interested in seeing how I extracted this string, maybe to find a better way to finally get the array out (he's really lonely and scared), here's how I did it:</p> <p>Originally, I had a two-pair <code>TJsonObject</code> named jObject</p> <pre><code>{ "id": 0, "data": "[{DAT_INCL: \"08/03/2012 10:07:08\", NUM_ORDE: 1, NUM_ATND: 1, NUM_ACAO: 2, NUM_RESU: 3}, {DAT_INCL: \"08/03/2012 10:07:09\", NUM_ORDE: 2, NUM_ATND: 1, NUM_ACAO: 4, NUM_RESU: 5}, {DAT_INCL: \"08/03/2012 10:07:09\", NUM_ORDE: 3, NUM_ATND: 1, NUM_ACAO: 8, NUM_RESU: NULL}]" } </code></pre> <p>I proceeded to extract the relevant <code>TJsonPair</code>, named jPair:</p> <pre><code>jPair := jObject.Get(1); </code></pre> <p>Which nets me this:</p> <pre><code>"data": "[{DAT_INCL: \"08/03/2012 10:07:08\", NUM_ORDE: 1, NUM_ATND: 1, NUM_ACAO: 2, NUM_RESU: 3}, {DAT_INCL: \"08/03/2012 10:07:09\", NUM_ORDE: 2, NUM_ATND: 1, NUM_ACAO: 4, NUM_RESU: 5}, {DAT_INCL: \"08/03/2012 10:07:09\", NUM_ORDE: 3, NUM_ATND: 1, NUM_ACAO: 8, NUM_RESU: NULL}]" </code></pre> <p>From that, I extracted the <code>String</code>, named sString</p> <pre><code>sString:= jPair.JsonValue.ToString; </code></pre> <p>Which nets me that string on the start of the question. And that is as good as it got, so far.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload