Joel Purra: Developer and more

jqnpm logotype, a Penrose triangle


Provide fallbacks for bad values.

This is a package for the command-line JSON processor jq. Install the package in your jq project/package directory with jqnpm:

jqnpm install joelpurra/jq-fallbacks


import "joelpurra/jq-fallbacks" as Fallbacks;

# Fallbacks::unlessNullFallback(<normal>; <fallback>)
"not null" | Fallbacks::unlessNullFallback("a"; "b"),  # "a"
null | Fallbacks::unlessNullFallback("a"; "b"),        # "b"

# Fallbacks::ifNull(<fallback>)
"not null" | Fallbacks::ifNull("a"),  # "not null"
null | Fallbacks::ifNull("a"),        # "a"

# Fallbacks::unlessNull(<fallback>)
"not null" | Fallbacks::unlessNull("a"),  # "a"
null | Fallbacks::unlessNull("a"),        # "not null"

# Fallbacks::nullAsObject
"not null" | Fallbacks::nullAsObject("a"),  # "not null"
null | Fallbacks::nullAsObject("a"),        # {}


Copyright (c) 2014, 2015, Joel Purra All rights reserved.

When using jq-fallbacks, comply to the MIT license. Please see the LICENSE file for details.

Background animations by hexagonif.