0

I have a string as following:

IngestDataRequestDto([email protected], ingestionDetails=IngestionDetails(selectedColumns={...

I want to convert this to IngestDataRequestDto.kt data class.

I tried to use deserilize with jackson and also direct casting but both not worked

  try {
      previousValue = SerializationService.deserialize(sample.previousValue, IngestDataRequestDto::class)
    } catch (e: Exception) {
      previousValue = sample.previousValue as IngestDataRequestDto
    }

try gives jackson error, catch string to object exception

1
  • can you give more details about error ? Commented May 14, 2020 at 13:47

1 Answer 1

1

That string seems to have been generated by a toString() call on some IngestDataRequestDto object, so it is not properly formatted as a Json or anything like that and, as such, can't be deserialized using these steps.

For this task, you'll need to make your own implementation of a deserializer, maybe using regex or, if that string always follows that format, you can make a template to extract the information you need.

Even though, this is definitely not the best way to do this and you should search for what generated that string in the first place and check if there's a better way to get that object's data.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.