■ .NET Newtonsoft.Json을 사용해 JSON 파일을 파싱하는 방법을 보여준다.
▶ setting.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
{ "MainFormLeft" : 52, "MainFormTop" : 52, "MainFormWidth" : 920, "MainFormHeight" : 690, "MainFormState" : "Maximized", "SkinStyle" : "The Bezier", "RibbonMinimized" : true, "SidebarStyle" : "NavigationPane", "SidebarWidth" : 100, "SidebarCollapsable" : false, "SidebarVisible" : true } |
▶ 실행 명령
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
$JSON = (Get-Content "d:\setting.json" -Encoding UTF8 | Out-String) [Reflection.Assembly]::LoadFile("d:\Newtonsoft.Json.dll") $Setting = [Newtonsoft.Json.Linq.JObject]::Parse($JSON) $Setting.Item("MainFormLeft" ).ToString() $Setting.Item("MainFormTop" ).ToString() $Setting.Item("MainFormWidth" ).ToString() $Setting.Item("MainFormHeight" ).ToString() $Setting.Item("MainFormState" ).ToString() $Setting.Item("SkinStyle" ).ToString() $Setting.Item("RibbonMinimized" ).ToString() $Setting.Item("SidebarStyle" ).ToString() $Setting.Item("SidebarWidth" ).ToString() $Setting.Item("SidebarCollapsable").ToString() $Setting.Item("SidebarVisible" ).ToString() |