Skip to content

How to prevent keys without values when creating key-value pairs #246

Answered by larsga
FoolMuun asked this question in Q&A
Discussion options

You must be logged in to vote

In this case I think I would first make the array, and then filter it later. Like this:

let props = [
	{"key": "manufacturer", "value" : .mfr},
	{"key": "ratedVoltage", "value" : .kV},
	{"key": "ratedCurrent", "value" : .amps}
]

{
	"AssetProperties": [for ($props) . if (.value)]
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@FoolMuun
Comment options

@larsga
Comment options

Answer selected by FoolMuun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
support Users asking how to solve a specific issue
2 participants