-1

I have a Json file that was deserialized from a Json Api-Call, now I have to use this file as an object in the main program.

Here is a small section of it:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace Api1
{
    public class EcmSimpleField
    {
        public string value { get; set; }
        public string displayName { get; set; }
        public string internalName { get; set; }
        public string dbName { get; set; }
        public bool visible { get; set; }
        public string type { get; set; }
    }

    public class BaseParameter
    {
        public string value { get; set; }
        public string type { get; set; }
    }

    public class SystemField
    {
        public string value { get; set; }
        public string type { get; set; }
    }

How can I use this file as an object in the main program and work with it?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
NB4K
  • 15
  • 2

2 Answers2

4

Create a class for the json like you shared above and use deserialise it using Newtonsoft.json dll or any other library.

var obj = JsonConvert.DeserializeObject<YourClass>(jsonString);
Vivek Mishra
  • 1,772
  • 1
  • 17
  • 37
0

This thread will probably help you: How can I parse JSON with C#?

If your JSON file has changing parameters then the parameters will need to be retrieved in arrays because the array index will always be the same even if the "parameter" changes.

Leo
  • 101
  • 8