}
else{
if(commaNeeded){
parentHasId = true;
}
Persistable schema = obj.getSchema();
Set<Map.Entry<String,Object>> entries= obj.entrySet(4);
boolean security = PersistableObject.isSecurityEnabled();
PersistableObject.enableSecurity(false);
Object propsObject = schema == null ? null : schema.get("properties");
boolean objectStarted = false;
try{
Persistable properties = propsObject instanceof Persistable ? (Persistable) propsObject : null;
if(objId.subObjectId == null && objId.source instanceof ClassDataSource)
objId = null; // this causes the output for root to still serialize identifi
PersistableObject.enableSecurity(security);
for (Map.Entry<String,Object> entry: entries) {
if(!objectStarted) {
writer.write(buffer.toString());
objectStarted = true;
}
String key = entry.getKey();
Object value = entry.getValue();
try {
if (!key.startsWith(":") && !("id".equals(key) && obj.getId().source != null))// || request.includeMetaData)
{
PersistableObject.enableSecurity(false);
Object propDef = properties == null ? null : properties.get(key);
Object lazyObject = propDef instanceof Persistable ? ((Persistable)propDef).get("lazy") : null;
lazy = lazyObject instanceof Boolean ? (Boolean) lazyObject : null;
Object conditional = propDef instanceof Persistable ? ((Persistable)propDef).get("shouldSerialize") : null;
if(conditional instanceof Function){
if(!ScriptRuntime.toBoolean(((Function)conditional).call(Context.enter(), GlobalData.getGlobalScope(), obj, new Object[]{}))){