Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't add an array element #96

Open
aben007 opened this issue Oct 15, 2018 · 1 comment
Open

Can't add an array element #96

aben007 opened this issue Oct 15, 2018 · 1 comment

Comments

@aben007
Copy link

aben007 commented Oct 15, 2018

string strJson = "{"ID": 3,"Weight":[{"ID": 1,"Weight": 24},{"ID": 2,"Weight": 33}]}";
var jd = JsonMapper.ToObject(strJson);
JsonData nd = new JsonData();
nd["ID"]=3;
nd["Weight"]=17;
jd["Weight"].Add(nd);
Console.Write(jd["Weight"].ToJson());
Console.Write(jd.ToJson());

The first output is right, but the second output jd.ToJson() not include nd

@aben007
Copy link
Author

aben007 commented Oct 15, 2018

temporary plan:
...
jd["Weight"].Add(nd);
jd["Weight"]=jd["Weight"];
...

Then output is ok, but that plan is... ugly...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant