Skip to content

Instantly share code, notes, and snippets.

@DawnImpulse
Last active March 12, 2022 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DawnImpulse/44d35178ce825a60067c1a6e4a457ede to your computer and use it in GitHub Desktop.
Save DawnImpulse/44d35178ce825a60067c1a6e4a457ede to your computer and use it in GitHub Desktop.
{
	"rest" : {
		"query: {
			"lang" : "",
			"map" : "",
			"name" : "",
			"age" : 2
		}
	}
}

Now if I just want 2 keys inside query, we can write a special restmap string

{rest{query{lang,map}}}

which will return only the required data

{
	"rest" : {
		"query: {
			"lang" : "",
			"map" : ""
		}
	}
}

Example 2 (escape)

{
	"rest" : {
		"query": {
			"lang" : "",
			"map" : "",
			"name" : "",
			"age" : 2,
			"something" : {
				"good": true,
				"is" : true,
				"here" : true
			}
		},		
	}
}

What if we need to remove just 1 or 2 keys and return all other keys. Suppose I need all keys inside rest.query except lang & map while also reducing rest.query.something

{rest{query{-lang,-map,something{good}}}} - marks the key as an escape key (you can also customize it; read more below)

which will return only the required data

{
	"rest" : {
		"query: {
			"name" : "",
			"age" : 2,
			"something" : {
				"good": true
			}
		},		
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment