• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: XMLlib library - somewhat.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XMLlib library - somewhat.


  • Subject: Re: XMLlib library - somewhat.
  • From: Shane Stanley <email@hidden>
  • Date: Sat, 03 May 2014 14:15:09 +1000

On 3 May 2014, at 2:08 pm, Shane Stanley <email@hidden> wrote:

So here's a starter ASObjC-based library:

And you might call it as below. There's only one catch: items in records that have a value of missing value are silently removed.

set theValue to {x:2, y:3, z:{4, 5, "abc"}}
tell script "^"
set theJSON to its convertASToJSON:theValue saveTo:(missing value)
log theJSON
set theAS to its convertJSONToAS:theJSON isPath:false
log theAS
set thePlist to its convertASToPlist:theValue saveTo:(missing value)
log thePlist
set theAS to its convertPlistToAS:thePlist isPath:false
log theAS
set thePlist to its convertJSONToPlist:theJSON isPath:false saveTo:(missing value)
log thePlist
set theJSON to its convertPlistToJSON:thePlist isPath:false saveTo:(missing value)
log theJSON
end tell

Returning:

--> 0000.001  (*{"x":2,"y":3,"z":[4,5,"abc"]}*)
--> 0000.002  (*x:2, y:3, z:4, 5, abc*)
--> 0000.002  (*<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>x</key>
<integer>2</integer>
<key>y</key>
<integer>3</integer>
<key>z</key>
<array>
<integer>4</integer>
<integer>5</integer>
<string>abc</string>
</array>
</dict>
</plist>
*)
--> 0000.003  (*x:2, y:3, z:4, 5, abc*)
--> 0000.003  (*<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>x</key>
<integer>2</integer>
<key>y</key>
<integer>3</integer>
<key>z</key>
<array>
<integer>4</integer>
<integer>5</integer>
<string>abc</string>
</array>
</dict>
</plist>
*)
--> 0000.004  (*{"x":2,"y":3,"z":[4,5,"abc"]}*)

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: XMLlib library - somewhat. (From: Alex Zavatone <email@hidden>)
 >Re: XMLlib library - somewhat. (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: XMLlib library - somewhat.
  • Next by Date: Re: I need help to customize email with AppleScript
  • Previous by thread: Re: XMLlib library - somewhat.
  • Next by thread: Quicktime export permissions.
  • Index(es):
    • Date
    • Thread