Skip to content

Using float converters on integer values

In its current implementation, the crawler is unable to assign a float value to a property if the value in the crawled data is given as int.

Consider the following cfood snippet

DictTest:
  type: Dict
  match: "(.*)"
  records:
    TestRec:
      parents:
        - TestRec
  subtree:
    float_element:
      type: DictFloatElement
      match_name: float_value
      match_value: "(?P<float_value>.*)"
      records:
        TestRec:
          float_prop: $float_value

and the dictionary to be crawled

test_dict = {
  float_value: 4
}

After crawling, TestRec will not be assigned a float_prop property since the integer value is never matched. If we use

test_dict2 = {
  float_value: 4.0
}

instead, the correct value is assigned.

Edited by Florian Spreckelsen