0

I have a string as below which needs to be converted to HashMap.

String datasample="{SessionID=ACVRT5678897DERT, Name=ACFGTYR, Age=34, sessionTime=20210428}"

I tried using Java 8 lambda ,stream and collect and it works when datasample does not include "{" and "}". But My string includes "{" and "}".

Please suggest.

Eritrean
  • 15,851
  • 3
  • 22
  • 28
user15345826
  • 41
  • 1
  • 1
  • 4

1 Answers1

1

If you have code that works when the characters "{" and "}" aren't present then couldn't you just remove these?

String dataSample="{SessionID=ACVRT5678897DERT, Name=ACFGTYR, Age=34, sessionTime=20210428}"
sampleToUse = dataSample.substring(1, dataSample.length() - 1);   //Remove 1st and last char
//run sampleToUse through your lambda
tomgeraghty3
  • 1,234
  • 6
  • 10