how do I add indents to the items in a list in .json (c#)

I would like something like:

My list
       Item 1
       Item 2
       Item 3  

Here's my current non-indenting code
     {  
      "type": "paragraph",
                  "content": "The following have limitations on the amount that can be claimed:",
                  "listofitems": [
                        { "itemtext": "my text her" },
                        { "itemtext": "my second line of text" },
                        { "itemtext": "my final line of text" }
                  ],
                  "listunstyled": false,
                  "isunordered": true
            },
PSCTECHAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
Please explain /with more detail what you mean by, "add indents to the items in a list in .json", what type of project, what control are you trying to interact with and what version of Visual Studio are you using.
0
PSCTECHAuthor Commented:
VS 2015

I am currently using a paragraph control with list of items. The indents I am talking about are shown below for Item1,2 and 3.  
I am open to using any control in the viewmodel .json that will result in text in the UI with spacing before it.  (see below example):

My list
       Item 1
       Item 2
       Item 3
0
Fernando SotoRetiredCommented:
I assume this is a Web app?
0
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

PSCTECHAuthor Commented:
yes
0
Fernando SotoRetiredCommented:
Hi PSCTECH;

Sorry it took a bit but have not done any web development in a while and getting old.
Added these two classes to the Models folder so to deserialize the json object into a .Net object
namespace WebApplication1.Models
{
    public class Rootobject
    {
        public string type { get; set; }
        public string content { get; set; }
        public Listofitem[] listofitems { get; set; }
        public bool listunstyled { get; set; }
        public bool isunordered { get; set; }
    }

    public class Listofitem
    {
        public string itemtext { get; set; }
    }

}

Open in new window

In the controller I materialized the json data into a .Net object and passed it to the view. Make sure that Newtonsoft.Json is installed and if not it can be installed through NuGet.
using WebApplication1.Models;
using Newtonsoft.Json;

public ActionResult Index()
{
    // Get the json string from where ever it is comming from
    string jsonMessage = "{      \"type\": \"pararaph\",    \"content\": \"The followin have limitations on the amount that can be claimed:\",    \"listofitems\": [        { \"itemtext\": \"Item 1 of the list of Items\" },        { \"itemtext\": \"Item 2 of the list of Items\" },        { \"itemtext\": \"Item 3 of the list of Items\" },        { \"itemtext\": \"Item 4 of the list of Items\" },        { \"itemtext\": \"Item 5 of the list of Items\" },        { \"itemtext\": \"Item 6 of the list of Items\" },        { \"itemtext\": \"my final Item\" }        ],    \"listunstyled\": false,    \"isunordered\": true}";
    // Convert it to a .Net object
    Rootobject jsonDataModel = JsonConvert.DeserializeObject<Rootobject>(jsonMessage);

    return View(jsonDataModel);
}

Open in new window

In the view I displayed the data as follows
@model WebApplication1.Models.Rootobject

@{
    ViewBag.Title = "Home Page";
}

...

<div>
    <p>
        @if (Model != null)
        {
            if (Model.listofitems != null)
            {
                <label>My List</label><br/>
                foreach (var item in Model.listofitems)
                {
                    <label>&nbsp&nbsp&nbsp @item.itemtext.ToString()</label><br/>
                }

            }
        }
    </p>
</div>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PSCTECHAuthor Commented:
Thank you very much for taking the time and putting in the effort on this.  I appreciate it very much.
0
Fernando SotoRetiredCommented:
Not a problem PSCTECH; glad I was able to help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.