package gameDesign; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import db.SqlHelper; import entity.UserInfo; import java.util.Iterator; import java.util.Map; public class GlobalVariableConstructor extends ElementConstructor { public GlobalVariableConstructor(SqlHelper helper, int botId) { super(); this.helper = helper; this.botId = botId; } public void construct(JSONObject jsonObject, UserInfo userinfo) { String category, name, description, attrName, attrValue; JSONArray globalVariable = jsonObject.getJSONArray("globalVariable"); Map attribute = null; Iterator attrIter = null; for (JSONObject variableList : globalVariable.toJavaList(JSONObject.class)) { category = (String) variableList.get("category"); attribute = JSONObject.toJavaObject(variableList.getJSONObject("variables"), Map.class); attrIter = attribute.keySet().iterator(); while (attrIter.hasNext()) { attrName = attrIter.next(); attrValue = attribute.get(attrName); varInitialMap.put(category + "_" + attrName, attrValue); } } } }