Created
June 12, 2013 14:06
-
-
Save touhami92/5765573 to your computer and use it in GitHub Desktop.
Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String getStringJSON(docFullName, property){ | |
this.setDocument(docFullName); | |
String propertyValue = this.theDoc.getValue(property, this.theObj); | |
if(!propertyValue || propertyValue == null) return "null"; | |
def propertyArray = propertyValue.split(','); | |
String json = "["; | |
String tempProp; | |
Document tempDoc; | |
Object tempsObj; | |
if(propertyArray.size() == 0){ | |
return ""; | |
}else{ | |
for(int i=0; i<propertyArray.size(); i++){ | |
if(propertyArray[i] != ""){ | |
if(xwiki.exists(propertyArray[i])){ | |
tempProp = xwiki.getUserName(propertyArray[i], "\$first_name \$last_name", false); | |
}else{ | |
tempProp = propertyArray[i]; | |
} | |
json = json + '{"value":"' + propertyArray[i] + '","name":"' + tempProp + '"}'; | |
if(i + 1 < propertyArray.size()){ | |
json = json + ','; | |
} | |
} | |
} | |
} | |
json += "]"; | |
return json; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment