Circe-Json retrieve all keys


#1

HI to every one,

I’m using circe, do you know if there any way to retrieve from json object a list with the keys?, for example:

{
	"key_1": "value_1",
	"key_2": {
		"key_3": "value_3",
		"key_4 ": "value_4"
	}
}

I would like to retrieve a list with this content: “key_1”,“key_2” , “key_3” , “key_4”

Thank you very much… :slight_smile:


#2

It’s not entirely clear to me how you want to handle different cases, for example, arrays.

Two examples (without handling arrays) are https://scastie.scala-lang.org/3HXuAPweT2CCn5ucZJwn9A

For the arrays, you also need a comparable asArray, that only handles values.