Converting return into json

24 views
Skip to first unread message

Ian Piper

unread,
Nov 30, 2020, 10:03:26 AM11/30/20
to EasyRdf Discussion
I'm using EasyRDF to manage  SPARL query to a remote data service. It works fine when I use a simple search box; I get a $return object and I can retrieve the separate results from that. However, I'd like to make the search box autocomplete and get the results in a dropdown as I type. The various resources I've read suggest that I need to build a piece of json and use that to populate the autocomplete list. However, I can't see how to make a json object out of the return from my program.

I've tried json_encode but that doesn't seem to work. Can anyone advise please? Any help much appreciated.

For information, here is the raw dump data that I get back from a typical search. This is just the first section and then the first array member. Apologies for any mangled formatting.

object(EasyRdf\Sparql\Result)#20 (4) {
  ["type":"EasyRdf\Sparql\Result":private]=>
  string(8) "bindings"
  ["boolean":"EasyRdf\Sparql\Result":private]=>
  NULL
  ["fields":"EasyRdf\Sparql\Result":private]=>
  array(2) {
    [0]=>
    string(7) "concept"
    [1]=>
    string(11) "searchLabel"
  }
  ["storage":"ArrayIterator":private]=>
  array(5) {
    [0]=>
    object(stdClass)#33 (2) {
      ["concept"]=>
      object(EasyRdf\Resource)#38 (2) {
        ["uri":protected]=>
        ["graph":protected]=>
        NULL
      }
      ["searchLabel"]=>
      object(EasyRdf\Literal)#40 (3) {
        ["value":protected]=>
        string(25) "Stomata and gas diffusion"
        ["lang":protected]=>
        string(2) "en"
        ["datatype":protected]=>
        NULL
      }
    }

k.ab...@gmail.com

unread,
Nov 30, 2020, 11:07:47 AM11/30/20
to EasyRdf Discussion

Hello,

one of the current EasyRdf maintainers here (k00ni).

Can you please open an issue at https://github.com/easyrdf/easyrdf/issues/new, because almost all communication is located on Github currently. Hope you understand.

Regards
Konrad Abicht
Reply all
Reply to author
Forward
0 new messages