example associate array in java and python

java not associate array it’s use Hashmap instead

import java.util.HashMap;
import java.util.Map;
 Map<String,String> test = new HashMap<String,String>();

python use dictionary instead

import json
import collections
test_dict = {'key':'value','key2':'value2'} #use dict for prepare return data
test_dict ['key'] = {'otherkey_in_root_key':'value3','otherkey_in_root_key2':'value4'}
result = json.dumps(test_dict) #json.dumps is parse array to json string format
self.write(result) #return json data to caller

Related posts:

This entry was posted in เกร็ดความรู้. Bookmark the permalink.