Open TAGC opened 6 years ago
The error occurs in JSON Deserializer.lvclass:Adapt To Type.vi
during a call to Set Data Name.vi
Also, like most things, the same thing is much more straightforward in C#:
void Main()
{
var json = @"
{
""foo"": {
""propA"": {},
""propB"": 1
}
}";
var root = JsonConvert.DeserializeObject<RootObject>(json);
root.Foo.PropB.Dump(); // 1
}
public class PropA
{
}
public class Foo
{
public PropA PropA { get; set; }
public int PropB { get; set; }
}
public class RootObject
{
public Foo Foo { get; set; }
}
It seems to work fine if the type definitions aren't wired to Unflatten From JSON String.vi
:
I'm not sure why.
This library is not able to deserialize JSON containing objects in which:
Given this JSON (call it "JSON A"):
And this JSON (call it "JSON B"):
Expected results
Both JSON A and B are valid, and JKI JSON should deserialize both without issue using
Unflatten From JSON String.vi
.Actual results
Unflatten From JSON String.vi
can deserialize JSON A without issue, but returns an error trying to deserialize JSON B:Steps to reproduce
Save this LabVIEW as a VI in some directory (call it
Run.vi
):Create a file
example.json
in the same directory.Copy JSON A into
example.json
and save.Execute
Run.vi
. There should be no error.Replace the contents of
example.json
with JSON B and save.Execute
Run.vi
. You should seeError Out
display error 1527.