Created
January 26, 2017 09:00
-
-
Save mgng/5b9e5e767bcab3ce60b236071a25ae46 to your computer and use it in GitHub Desktop.
VBScript で JSON 文字列 を使う
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
option Explicit | |
dim doc, jsonStr, js, elm | |
set doc = CreateObject("htmlfile") | |
jsonStr = "{""user"":{""id"":""mgng"", ""name"": ""ムグ""}}" | |
js = _ | |
"var json = " & jsonStr & ";" & _ | |
"var div = document.createElement('div');" & _ | |
"div.setAttribute('id', 'id_elm');" & _ | |
"div.setAttribute('data-id', json.user.id);" & _ | |
"div.setAttribute('data-name', json.user.name);" & _ | |
"document.appendChild(div);" | |
doc.parentWindow.execScript js, "JavaScript" | |
set elm = doc.getElementById("id_elm") | |
WScript.Echo elm.getAttribute("data-id") | |
WScript.Echo elm.getAttribute("data-name") | |
' mgng | |
' ムグ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment