0

anybody know how to achieve that with a c# code

"cards": {
      "en-US": [{
              "sys": {
                "type": "Link",
                "linkType": "Entry",
                "id": "id"
              }
      } ]
  }

this is my coded

Cards = new Dictionary<string, List<Sys>>()
            {
                { "en-US" , new List<Sys>{ new Sys { id = "7Ll4cezI6QMYsgIUwMCmSw", type = "Link", linkType = "Entry" } } }
            }

and a sys class

public class Sys
{

    public string id { get; set; }
    public string type { get; set; }
    public string linkType { get; set; }


}

but what im acheiving here is

"Cards":{"en-US":[{"id":"id","type":"Link","linkType":"Entry"}]}

and what i want is the "sys" that is not coming , any help

1
  • You need a SysContainer class with a single property sys. Then your list should be List<SysContainer> Commented Sep 14, 2018 at 16:18

1 Answer 1

1

Try this:

    public class SysParent
    {
        public Sys sys { get; set; }
    }

    public class Sys
    {

        public string id { get; set; }
        public string type { get; set; }
        public string linkType { get; set; }


    }

        var Cards = new Dictionary<string, List<SysParent>>()
        {
            { "en-US" , new List<SysParent>{ new SysParent{
                sys = new Sys { id = "7Ll4cezI6QMYsgIUwMCmSw", type = "Link", linkType = "Entry" } }
            } }
        };

This way you add a parent object with name sys.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.