Posts

Showing posts with the label JSON

timezone ile bagli Jackson deserializableda problem

  demeli date save olanda duzgun vaxtla save olur bazaya  ,ama qayidanda jackson deserializable levelinde ilishir ve 4 saat dala gorsenir swaggerde , bunun helli uchun: bu problem hem @CreationTimestamp ve @UpdateTimestamp da hem de el ile daxil olunan date larda da bash verir app propertiese 2 setr eleve edirik jackson serizable-deserizable emelyati uchun : spring.jackson.serialization.write-dates-with-zone-id=true spring.jackson.time-zone=GMT+4

object to json , json to object for controller integration testing

import com.fasterxml.jackson.core.JsonProcessingException ; import com.fasterxml.jackson.databind.ObjectMapper ; import com.fasterxml.jackson.databind.SerializationFeature ; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule ; public class TestsHelper { public static String getJsonString (Object object) throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper() ; mapper.registerModule( new JavaTimeModule()) ; mapper.disable(SerializationFeature. WRITE_DATES_AS_TIMESTAMPS ) ; return mapper.writeValueAsString(object) ; } public static < T > T getObjectFromJson (String json , Class< T > type) throws JsonProcessingException{ ObjectMapper mapper = new ObjectMapper() ; mapper.registerModule( new JavaTimeModule()) ; mapper.disable(SerializationFeature. WRITE_DATES_AS_TIMESTAMPS ) ; return mapper.readValue(json , type) ; } } use case in testing class : private OfficePhoto request...