`ActionContext.GetContext<string>("property")` returns json token of `{{ ValueKind: 3}}` instead of actual value.
See original GitHub issueHi,
I’m using 3.2.0.
I have a custom action in a action trigger:
public class PropertySetterAction : ActionBase
{
private readonly RuleExpressionParser _expressionParser;
public PropertySetterAction(RuleExpressionParser expressionParser, object input)
{
_expressionParser = expressionParser;
}
public override ValueTask<object> Run(ActionContext context, RuleParameter[] ruleParameters)
{
var propertyName = context.GetContext<string>("propertyName");
var value = context.GetContext<string>("newValue");
return new ValueTask<object>(this._expressionParser.Evaluate<object>(value, ruleParameters));
}
}
Debugger view:
My Rules look like this:
[
{
"WorkflowName": "Employee Validations",
"Rules": [
{
"RuleName": "If Employee Last name is unset, use first name as last name",
"Expression": "!string.IsNullOrWhiteSpace(input1.LastName)",
"Actions": {
"OnFailure": {
"Name": "PropertySetterAction",
"Context": {
"propertyName": "LastName",
"newValue": "input1.FirstName"
}
}
}
}
]
}
]
My expectation is that propertyName
in context would be the literal LastName
and the value of newValue
would be evaluated to an expression.
Am I missing something or is there a defect?
Issue Analytics
- State:
- Created 2 years ago
- Comments:10
Top Results From Across the Web
dynamic c# ValueKind = Object - asp.net core
Json which introduce new JsonElement ValueKind so ValueKind is from System.Text.Json library and JsonConvert is from Newtonsoft library.
Read more >.Net 6 - Rest Api is deserializing property of "object" type to ...
When I first tried saving the data, it wrote {"ValueKind": 4} to the database instead of raw value I was expecting. Throwing errors...
Read more >How to use a JSON DOM in System.Text.Json
Create a DOM from a JSON string; Write JSON from a DOM. Get a value, object, or array from a DOM. C#
Read more >JsonElement.ValueKind Property (System.Text.Json)
Gets the type of the current JSON value.
Read more >Deserialization with System.Text.Json - Marc Roussy
An overview of the many ways of deserializing JSON with System. ... each JSON token all the while keeping memory usage down to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ElanHasson I digged deeper into the issue and realized that
System.Text.Json
does not play well with Object type and generates valuekind like object. https://josef.codes/custom-dictionary-string-object-jsonconverter-for-system-text-json/It looks like something beyond the scope of this library, and we would recommend using Newtonsoft (or pass the json as string) till we are able to fully migrate to System.Text.Json
I will be closing this issue for now and will include this as a part of documentation
@abbasc52, what is the work necessary to support? I can send a PR.
Any interest in supporting whatever serializer via configurable extensibility points in
ReSettings
?