Skip to content
This repository has been archived by the owner on Jun 1, 2021. It is now read-only.

jqnpm/jq-fallbacks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jqnpm logotype, a Penrose triangle

Provide fallbacks for bad values.

⚠️ This project has been archived

No future updates are planned. Feel free to continue using it, but expect no support.

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

Usage

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"),        # {}

License

Copyright (c) 2014, 2015, Joel Purra https://joelpurra.com/ All rights reserved.

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