Skip to content

Instantly share code, notes, and snippets.

@wk-j
Created January 19, 2021 06:34
Show Gist options
  • Save wk-j/eadc4a2e9bde407c95447e2f6773de64 to your computer and use it in GitHub Desktop.
Save wk-j/eadc4a2e9bde407c95447e2f6773de64 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
namespace Request
{
public class Settings
{
public RequestApi[] RequestApi { set; get; }
}
public class RequestApi
{
public string ProcessId { set; get; }
public Children[] Children { set; get; }
}
public class Children
{
public string FormId { set; get; }
public Dictionary<string, Value> Value { set; get; }
}
public class Value
{
public string Id { set; get; }
public string Name { set; get; }
}
class Program
{
static void Main(string[] args)
{
var json = File.ReadAllText("resource/A.json");
var obj = JsonConvert.DeserializeObject<Settings>(json);
Console.WriteLine(obj.RequestApi[0].Children[0].Value["agree_to_1"].Id);
}
}
}
@wk-j
Copy link
Author

wk-j commented Jan 19, 2021

{
    "requestApi": [
        {
            "processId": "Process_sid-1D5CEC2F-AD25-4724-910B-A4FB70A0EA2D",
            "children": [
                {
                    "formId": "sid-C1A1F9FD-4556-44AE-82C0-5EE45F92A43F",
                    "value": {
                        "agree_to_1": {
                            "id": "yes",
                            "name": "เห็นชอบ"
                        }
                    }
                },
                {
                    "formId": "sid-C458996A-4EEF-4E7C-9C2A-F318FBF0BBB6",
                    "value": {
                        "approve_to_1": {
                            "id": "yes",
                            "name": "อนุมัติ"
                        }
                    }
                },
                {
                    "formId": "sid-CB030662-4451-424D-8A1B-2CA1826AA514",
                    "value": {
                        "agree_to_2": {
                            "id": "yes",
                            "name": "เห็นชอบ"
                        }
                    }
                },
                {
                    "formId": "sid-3690C365-E786-4861-B709-558609E51A92",
                    "value": {
                        "approve_to_2": {
                            "id": "yes",
                            "name": "อนุมัติ"
                        }
                    }
                },
                {
                    "formId": "sid-1D5CEC2F-AD25-4724-910B-A4FB70A0EA2D",
                    "value": {
                        "agree_to_3": {
                            "id": "yes",
                            "name": "เห็นชอบ"
                        }
                    }
                },
                {
                    "formId": "sid-B34D453B-FD7C-4FF9-896E-15F811355216",
                    "value": {
                        "approve_to_3": {
                            "id": "yes",
                            "name": "อนุมัติ"
                        }
                    }
                },
                {
                    "formId": "sid-5EC0CAB8-D128-4733-9476-D3BCF0051FEF",
                    "value": {
                        "approve_to_4": {
                            "id": "yes",
                            "name": "อนุมัติ"
                        }
                    }
                }
            ]
        }
    ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment