Mapping to custom objects
class News: Serializable {
var title: String?
var img: MBImage?
}val fieldsMapping = MBFieldsMapping()
//”ttl” is my custom object element, “Title” is the name of the Element we want to map from the section
fieldsMapping.putMap(“ttl”, “Title”)
//”img” is my custom object element, “Images” is the name of the Element we want to map from the section, we add “imageArguments” which tells to take only the first image from the array.
val imageArguments = arrayOf(MBMappingArgs.mapping_first_image_media)
fieldsMapping.putMap(“img”, “Images”, imageArguments)
//If getSimpleValues was “true” we would not have a single MBImage but the basic value, so the URL of the image and News class “img” should be a String
val getSimpleValues = false;
val nws = MBurgerMapper.mapToCustomObject(nkSection, fieldsMapping, News(), getSimpleValues) as NewsLast updated