Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Get value from JSON response in C#

Need help regarding search or get value in JSON response I try to get value of "id"

"{\"items\":[{\"libId\":\"gc1373wgw1mamn8baegfg2q2tsw4lnv1\",\"id\":\"bya51p40751d6oh0e653d5j645st5abk\",\"createdAt\":\"2023-08-10T13:06:05.985Z\",\"createdBy\":\"f393281c-265e-4116-95fd-804e2c10ef5a\",\"modifiedAt\":\"2023-08-14T12:53:29.645Z\",\"modifiedBy\":\"f393281c-265e-4116-95fd-804e2c10ef5a\",\"v\":2,\"name\":\"Steel Status\",\"schema\":{\"v\":1,\"props\":{\"prop_7jf006f02m19eilzpql7hziuonnajtaj\":{\"type\":\"boolean\",\"required\":true,\"default\":false},\"prop_cvelncsngupkcsczuwpbzpb8wvckvmo9\":{\"type\":\"boolean\",\"required\":true,\"default\":false}}},\"i18n\":{\"__definition-sort-order__\":{\"name\":\"__definition-sort-order__\",\"props\":{\"__definition-sort-order__\":\"0\"}},\"en-US\":{\"name\":\"Steel Status\",\"props\":{\"prop_7jf006f02m19eilzpql7hziuonnajtaj\":\"fabrication\",\"prop_cvelncsngupkcsczuwpbzpb8wvckvmo9\":\"Erection\"}},\"__prop-order__\":{\"name\":\"__prop-order__\",\"props\":{\"prop_7jf006f02m19eilzpql7hziuonnajtaj\":\"0\",\"prop_cvelncsngupkcsczuwpbzpb8wvckvmo9\":\"1\"}}},\"_actions\":[\"pset:GetDefVersionSchema\",\"pset:GetDefVersion\",\"pset:GetDefVersions\",\"pset:GetDef\",\"pset:UpdateDef\",\"pset:ValidatePSets\",\"pset:Subscribe\",\"pset:GetPSet\",\"pset:ListPSets\",\"pset:PutPSet\"]}]}"

I try below solutions but it get null

JObject obj = JObject.Parse(responseBody);
string id = (string)obj["id"];
var datas = (JObject)JsonConvert.DeserializeObject(responseBody);
string nodid = datas["id"].Value<string>();

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

obj["items"][0]["id"]

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading