I am getting a null value for my transformed object when trying to convert something like this:
{
"employees": [
{ "f_name" : "tom", "l_name" : "smith" },
{ "f_name" : "don", "l_name" : "jones" }
]
}
to this:
{
"employees": [
{ "firstName" : "tom", "lastName" : "smith" },
{ "firstName" : "don", "lastName" : "jones" }
]
}
This is the spec I am using:
[
{
"operation" : "shift",
"spec" : {
"employees" : {
"f_name" : "firstName",
"l_name" : "lastName"
}
}
]
This is the code I am using:
List<Object> chainrSpecJSON = JsonUtils.classpathToList("path/spec.json");
Chainr chainr = Chainr.fromSpec(chainrSpecJSON);
Object inputJSON = JsonUtils.classpathToObject("path/input.json");
Object transformed = chainr.transform(inputJSON);
System.out.println(transformed);
I was able to successfully transform the following input with the same spec and code as above:
{
"employees":
{ "firstName" : "tom", "lastName" : "smith" }
}
So what do I need to do to transform an array of employee objects?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…