Specify value for map<string, string> parameter in cronJob seed data


#1

For example, I have a following function,

type A {
  func_b: function(fields: map<string, string>)
}

And following cronJob seed data:

{
  "description" : "cronJob",
  "action" : {
    "actionName" : "func_b",
    "typeName" : "A"
  },
  "inputs" : {
    "fields": {
      "type" : {
        "name" : "MappObj"
      },
      "value": {
        "key_A": "value_A"
      }
    }
  },
  "concurrent" : false,
  "scheduleDef" : {
    "cronExpression" : "0 10 * * * ?",
    "skipOverdue" : true
  },
  "id" : "the id"}

However, this raises below error when the cronJob gets triggered,

Map has wrong value type "map<string, any>" (expected map<string, string>)

Is it possible to pass in value for fields parameter?


#2

Did you try setting fields to a map<string, string> ?

{
  "description" : "cronJob",
  "action" : {
    "actionName" : "func_b",
    "typeName" : "A"
  },
  "inputs" : {
    "fields": {
      "key_A": "value_A"
    }
  },
  "concurrent" : false,
  "scheduleDef" : {
    "cronExpression" : "0 10 * * * ?",
    "skipOverdue" : true
  },
  "id" : "the id"
}

#3

Yes, tried that.

  "inputs" : {
    "fields": {
      "key_A": "value_A"
    }
  }

returns below error

reason=c3.love.exceptions.C3RuntimeException: Expecting specific type for fields with 'any', 'anyof' or 'Obj' type at JSON document at 18:43, message: Expecting specific type for fields with 'any', 'anyof' or 'Obj' type at JSON document

#4

We had a similar issue with an array field and this worked:
“inputs” : {
“scoreNames” : {type: “Boxed<[string]>”, value: [ “General”, “Vibration” ]}
}

Maybe we can do something similar for a map?