Imagine a method accepting 2 string arguments:
public int Method(string expression, string variables) { ... }
"expression" is expected to be a math. expression (e.g. "1 + 2") that needs to be evaluated. And if there's something except for numbers & operators, I need to look up for that variable in "variables" string argument, to replace that variable with the number it represents. (There's no guarantee that the variable is defined in "variables", but I believe it's not important here).
Input example:
Method("351 + x", "{ \"x\":69 }");
// Expected output: 420
Example of other valid "variables" values:
- { "x":123 }
- { "x":123, "y":420 }
- { }
- { "z":69 }
- { "abc": 777 }
I wonder what's a good way to parse & retrieve data from a JSON (that may have a different structure each time (i.e. different number of properties & names)), to map it with the variable in "expression" string?