Learn R Programming

valdr (version 2.0.0)

.safe_extract_first: Safely extract the first non-empty field from a list of lists

Description

Internal helper function used to extract the first non-empty value from a list of fields, in order, from a list of records. If all fields are NULL or empty strings, returns "".

Usage

.safe_extract_first(x, fields)

Value

A character vector containing the extracted values, with NULLs replaced by "". Internal function (not designed to be used directly by end users)

Arguments

x

A list of lists (records), coming from parsed JSON API responses.

fields

A character vector naming the candidate fields to check in order.