AppleScript名:YAMLのじっけん |
— Created 2017-02-16 by Takaaki Naganoya — 2017 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "YAML" –https://github.com/mirek/YAML.framework –YAMLの文字列からオブジェクトを生成する set aYAMLstr to " items: – name: Foo – name: Bar " set aStr to current application’s NSString’s stringWithString:aYAMLstr set aData to aStr’s dataUsingEncoding:(current application’s NSUTF8StringEncoding) set aData to (current application’s YAMLSerialization’s objectsWithYAMLString:aStr options:(4096) |error|:(missing value)) as list of string or string log result –> {{items:{{name:"Foo"}, {name:"Bar"}}}} –オブジェクトからYAMLの文字列を取得する set aString to (current application’s YAMLSerialization’s createYAMLStringWithObject:aData options:(1) |error|:(missing value)) as string (* –> "— – items: – name: Foo – name: Bar …" *) |
More from my site
(Visited 37 times, 1 visits today)