본문 바로가기
  • 환영 합니다 ! Welcome!
VBA For Windchill

json 파일 읽기

by ToolBOX01 2024. 6. 26.
반응형

□ json 파일 

{
		"Name":"TestWTPart_001",
		"AssemblyMode": {
		"Value": "separable",
		"Display": "Separable"
	},

		"PhantomManufacturingPart" : false,
		"Context@odata.bind": "Containers('OR:wt.pdmlink.PDMLinkProduct:48507000')"
}

위 파일은 "C:\PTC\WORK90\example.JSON" 파일 이름으로 저장 되어 있습니다

□ 코드

Option Explicit
Public Sub exceljson()
                Dim JSON, jsonObject  As Object
                Dim JsonText As String
                Dim i As Integer
                Dim FSO As New FileSystemObject
                Dim JsonTS As TextStream
                Set JsonTS = FSO.OpenTextFile("C:\PTC\WORK90\example.JSON ", ForReading)
                JsonText = JsonTS.ReadAll
                
                Debug.Print JsonText
                JsonTS.Close
                Set JSON = JsonConverter.ParseJson(JsonText)
                
                MsgBox JSON("Name")
                Set jsonObject = JSON("AssemblyMode")
                MsgBox jsonObject("Value")
                MsgBox jsonObject("Display")
                MsgBox JSON("PhantomManufacturingPart")
                MsgBox JSON("Context@odata.bind")
         
End Sub

 

참고 사이트

 

Import Json to excel and export excel to Json (Updated 2022) - Coding is Love

Excel doesn't have built-in support for JSON. Learn how to parse JSON in Excel VBA, import JSON to Excel and export Excel data using VBA-JSON.

codingislove.com

 

JSON 파일 유효성 검사

 

JSON Online Validator and Formatter - JSON Lint

Loading... About the JSONLint Editor JSONLint is a validator and reformatter for JSON, a lightweight data-interchange format. Copy and paste, directly type, or input a URL in the editor above and let JSONLint tidy and validate your messy JSON code. What Is

jsonlint.com