Search code examples
javaphpthriftthrift-protocol

Can I return a list of maps in thrift?


I am trying to return a array of hashmaps from Java to php.
What I want in php is this :
Array :
[0] =>
['abc'] = "blah blah abc"
['def'] = "blah blah def"
['ghi'] = "blah blah ghi"
[1] =>
['abc'] = "blah blah pqr"
['def'] = "blah blah stu"
['ghi'] = "blah blah xyz"

What is the best way to do it through Java <=> thrift <=> php ?


Solution

  • Ok,
    I've done like this so far :

    my Thrift file :
    namespace java lserver.gen
    service LuceneServer {
    list<map<string,string>> search(1:string term)
    }

    in Java I return an ArrayList like so :
    HashMap<String, String> res = new HashMap();
    ArrayList<HashMap> result = new ArrayList<HashMap>();
    //blah blah blah
    return result;

    So in php I can access as mentioned in question...

    But certainly I've no idea if that is the most efficient way of doing this...