I have a string like - {"state":1,"cmd":1}
, I need to compare this with generated output but in the generated output the order keeps changing i.e. sometimes its {"state":1,"cmd":1}
other times its {"cmd":1,"state":1}
.
Currently I was using equals()
method to compare, What can be better way in this scenario to validate the two strings. My concern is just that both entries are present in string, order is not imp.