Conditional Parsers
  • 13 Dec 2022
  • 2 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Conditional Parsers

  • Dark
    Light
  • PDF

Article summary

The abstract parser - boolean is the parent for a variety of parsers which evaluate or load data from one or more columns in a source data table. It inherits attributes and behaviors from its parent: abstract parser - column.

As an abstract type, it is not possible to instantiate a boolean type parser - only its child types.

Parser types which inherit from the boolean type are designed to do two potential things:

  1. Evaluate source data fields into true, false, or null based on values from a column in the source data. This is a common case when an inner boolean parser is used as the value of the where attribute in another parser, or as the value of the include or exclude attribute of a table object. Thus, in this context, the boolean parser is simply a conditional function used by other objects.
  2. Create and load data into categorical variables within collections. In this scenario, the boolean type parser is a peer with all other parsers in the parsers attribute of a table object or in the parsers attribute of the config file.

In the second case, where boolean parsers are used to load data into categorical variables within collections, the parsers will typically include some of the common attributes.

Attribute - true_value

The true_value attribute is not required, and will not be used in case 1 above. It will optionally be used in case 2 above, and will generate the variable name in the case where the parser evaluates to true.

{
  "parser_type": "bbbb", 
  "column": "cccc",
  
  // The true_value attribute is used to map entities to a categorical 
  // variable when the parser condition resolves to true.
  //
  // NOTE - NULL IS NOT FALSE. This isn't JavaScript.
  //
  "true_value": "I'm true!"
}

Attribute - true_value as a parser

{
  "parser_type": "bbbb", 
  "column": "cccc",
  
  // The true_value attribute can also dynamically pull a categorical
  // value from another column in the source data using a parser.
  //
  // NOTE - NULL IS NOT FALSE. This isn't JavaScript.
  //
  "true_value": {...}
}

Attribute - false_value

The false_value attribute is not required, and will not be used in case 1 above. It will optionally be used in case 2 above, and will generate the variable name in the case where the parser evaluates to false.

{
  "parser_type": "bbbb", 
  "column": "cccc",
  
  // The false_value attribute is used to map entities to a categorical 
  // variable when the parser condition resolves to false.
  //
  // NOTE - NULL IS NOT FALSE. This isn't JavaScript.
  //
  "false_value": "I'm false!"
}

Attribute - false_value as a parser

{
  "parser_type": "bbbb", 
  "column": "cccc",
  
  // The false_value attribute can also dynamically pull a categorical
  // value from another column in the source data using a parser.
  //
  // NOTE - NULL IS NOT FALSE. This isn't JavaScript.
  //
  "false_value": {...}
}

Was this article helpful?