#StackBounty: #.net #json #botframework Form builder fields from dynamic JSON

Bounty: 50

I want to populate a form with fields that are both manually added and dynamically added.

public class ModelClass
            public string URL { get; set; }
            public string Title { get; set; }


 public IForm<ModelClass> BuildApplyform()
            var builder = new FormBuilder<ModelClass>(); 
            // Parse string to json for usage in the foreach
            dynamic json = JObject.Parse(jsonString);

            builder.Message("Form builder");
            builder.Field(nameof(ModelClass.Title), active: (state) => false);
            builder.Field(nameof(ModelClass.URL), active: (state) => false);
            foreach(string param in json.Parameters)
            return builder.Build();

The JSONstring is very dynamic and can be different every time. However, the string always contains the “d” and “parameter”childnodes.
The string could look like:

  nt"d":  {
    ntt"parameters":  [
        nttt"id":  "url",
        nttt"name":  "Site URL",
        nttt"required":  "text"
        nttt"id":  "title",
        nttt"URL":  "Title",
        nttt"required":  true,
        nttt"example":  "www.stackoverflow.com"ntt

How can I make sure that no matter what the JSON looks like, the parameters are dynamically added as field input’s in the form builder?
Thanks in advance.

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.