diff --git a/src/java/es/upm/dit/gsi/jason/utils/CollectionUtils.java b/src/java/es/upm/dit/gsi/jason/utils/CollectionUtils.java index b4cb3ce..4d45413 100644 --- a/src/java/es/upm/dit/gsi/jason/utils/CollectionUtils.java +++ b/src/java/es/upm/dit/gsi/jason/utils/CollectionUtils.java @@ -6,8 +6,13 @@ package es.upm.dit.gsi.jason.utils; import jason.asSyntax.Literal; import java.util.Collection; +import java.util.Iterator; import java.util.LinkedList; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + /** * * Project: Web40SOJason @@ -84,4 +89,60 @@ public abstract class CollectionUtils { return strArray; } + + public static String toPerceptsObject(JSONObject jso){ + StringBuilder sb = new StringBuilder(); + Iterator it = jso.keys(); + while(it.hasNext()){ + String key = it.next(); + try { + Object temp= jso.get(key); + String res = toPercepts(temp); + sb.append(key+"("); + sb.append(res); + sb.append(")"); + } catch (JSONException e) { + e.printStackTrace(); + } + if(it.hasNext()){ + sb.append(","); + } + } + return sb.toString(); + + } + + public static String toPerceptsArray(JSONArray jsa){ + StringBuilder sb = new StringBuilder(); + int top = jsa.length(); + int topm = top-1; + sb.append("["); + for(int i=0;i