How get JSON response which is sorted by its keys?

At first I get JSON

.check(jsonPath("$.result").ofType[Map[String,Any]].find.saveAs(“profile”)

Then I need to check that the json from response equals to the above json

.check(jsonPath("$.result") is “${updatedJson}”)

The problem is that both JSONs are equal but the keys are mixed.
As far as I understood StringBody is sorting keys.
How can I get JSON with sorted keys?

I tried to use SortedMap instead of Map but failed

seems that I found the solution, waiting for your comments :slight_smile:

  1. Change map to mutable
  2. Change some values in the map (if needed)
  3. Create new SortedMap based on the previous

val myMap = session.attributes(“profile”).asInstanceOf[Map[String,Any]]
val myMutableMap = collection.mutable.Map(myMap.toSeq: *)
// Modify some field values in the returned JSON object (which is scala map, actually)

val sortedMap = SortedMap(myMutableMap.toSeq:
*)

2015-12-14 18:16 GMT+02:00 fire flex <fireflex777@gmail.com>: