mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merged BRANCHES/DEV/V4.1-BUG-FIX to HEAD
44117: ALF-16979 - Invalid JSON template is produced when 'Infinity' or '-Infinity' values are rendered by ?c FreeMarker built-in. Also fixes number output when rendered by JSONConversionComponent.propertyToJSON() Java backed JSON output. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@44119 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -32,6 +32,7 @@ import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ISO8601DateFormat;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.json.JSONException;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONAware;
|
||||
import org.json.simple.JSONObject;
|
||||
@@ -298,12 +299,21 @@ public class JSONConversionComponent
|
||||
else if (value instanceof List)
|
||||
{
|
||||
// Convert the List to a JSON list by recursively calling propertyToJSON
|
||||
List jsonList = new ArrayList(((List) value).size());
|
||||
for (Object listItem : (List) value) {
|
||||
jsonList.add(propertyToJSON(nodeRef, propertyName, key, (Serializable) listItem));
|
||||
}
|
||||
List<Object> jsonList = new ArrayList<Object>(((List<Serializable>) value).size());
|
||||
for (Serializable listItem : (List<Serializable>) value)
|
||||
{
|
||||
jsonList.add(propertyToJSON(nodeRef, propertyName, key, listItem));
|
||||
}
|
||||
return jsonList;
|
||||
}
|
||||
else if (value instanceof Double)
|
||||
{
|
||||
return (Double.isInfinite((Double)value) || Double.isNaN((Double)value) ? null : value.toString());
|
||||
}
|
||||
else if (value instanceof Float)
|
||||
{
|
||||
return (Float.isInfinite((Float)value) || Float.isNaN((Float)value) ? null : value.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
return value.toString();
|
||||
@@ -338,11 +348,9 @@ public class JSONConversionComponent
|
||||
catch (NamespaceException ne)
|
||||
{
|
||||
// ignore properties that do not have a registered namespace
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Ignoring property '" + propertyName + "' as its namespace is not registered");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return propertiesJSON;
|
||||
|
Reference in New Issue
Block a user