Thanks. I have added additional code to the JsonSerializer module which copes with serializing the primitives based on a subclass of the Primitive entity and it works really well now. I added it for interest
else if (member instanceof MendixObjectReferenceSet){ JSONArray ar = new JSONArray();
if (value != null) {
@SuppressWarnings("unchecked")
List<IMendixIdentifier> ids = (List<IMendixIdentifier>) value;
for(IMendixIdentifier id : ids) if (id != null) {
//primitive
IMendixObject obj = Core.retrieveId(context, id); //Optimize: for refset use retrieve ids
if (obj != null) {
String objType = obj.getType();
if (Core.isSubClassOf(Primitive.entityName, objType)) {
Primitive prim = Primitive.initialize(context, obj);
if (prim.getPrimitiveType() == RestPrimitiveType.String){
ar.put(prim.getStringValue(context));
}
else if(prim.getPrimitiveType() == RestPrimitiveType._Boolean){
ar.put(prim.getBooleanValue());
}
else if(prim.getPrimitiveType() == RestPrimitiveType.Number){
ar.put(prim.getNumberValue());
}
else if(prim.getPrimitiveType() == RestPrimitiveType._NULL){
ar.put(JSONObject.NULL);
}
}
else{
Object url = identifierToJSON(context, id, alreadySeen);
if (url != null)
ar.put(url);
}
}
}
}
target.put(Utils.getShortMemberName(memberName), ar);
}
To serialize plain json values, you can use the JsonPrimitive entity which is already available in the module by default. So if you create a referenceset named 'groups' that points to json primitives, you should be able to generate the desired json structure.
Michel, I linked routes to "primitive" in the RestServices Module and set the primitive type to String and got the following Json { "id": "31dab5452a", "groups": [{ "PrimitiveType": "String", "NumberValue": 0, "BooleanValue": false, "StringValue": "Koegel" }], "name": "Birding", "type": "checkboxes", "apikey": "xxxxxx" }
Am a linking to the wrong object ?