var config = new MapperConfiguration(cfg => cfg.CreateMap() .ForMember(dest => dest.FullName, opt => opt.MapFrom(src => src.Name)) .ForMember(dest => dest.YearsOld, opt => opt.MapFrom(src => src.Age))); var mapper = config.CreateMapper(); var customer = new Customer { Name = "John Doe", Age = 30 }; var customerDto = mapper.Map (customer);
string json = @"{ 'name': 'John Doe', 'age': 30 }"; var customer = JsonConvert.DeserializeObjectIn this example, we have a JSON string representing a customer object. We use the JsonConvert class's DeserializeObject method to deserialize the JSON string into a Customer object. Overall, IObjectMapper Map is a useful method for mapping objects between different types and libraries, and is commonly used in C# applications that deal with serialization, deserialization, and data transfer.(json);