开发者

Can I return a list of maps in thrift?

开发者 https://www.devze.com 2023-02-15 06:19 出处:网络
I am trying to return a array of hashmaps from Java to php. What I want in php is this : Array : [0] =>

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 bla开发者_开发百科h stu"

['ghi'] = "blah blah xyz"

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


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...

0

精彩评论

暂无评论...
验证码 换一张
取 消