Skip to content

Instantly share code, notes, and snippets.

@mgng
Created January 26, 2017 09:00
Show Gist options
  • Save mgng/5b9e5e767bcab3ce60b236071a25ae46 to your computer and use it in GitHub Desktop.
Save mgng/5b9e5e767bcab3ce60b236071a25ae46 to your computer and use it in GitHub Desktop.
VBScript で JSON 文字列 を使う
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