• 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: [applescript] Tearing my bloody hair out.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [applescript] Tearing my bloody hair out.


  • Subject: Re: [applescript] Tearing my bloody hair out.
  • From: Brian Christmas <email@hidden>
  • Date: Sat, 16 Sep 2017 16:54:17 +1000

Further to this matter

I had realized that the fact that the keys were in Quotes in jsonURL meant that
it wasn’t really a Dictionary, but thought there might be some simple way to
change it, so posted.

But, no fast answers, so after thinking, wrote the following Script 1

However, it’s not recognized still as a Dictionary, and I don’t know why. If I
take the EXACT list, and use it in Script 2, it works fine.

There’s obviously something I’m missing, but I thought coercing temp to a list
would fix any hassles.

BTW, I’ve tried stripping the square brackets as text item delimiters, but it
fails.

Anybody able to set me straight, please?

Regards

Santa


SCRIPT 1

use AppleScript version "2.4"
use framework "Foundation"
use framework "AppKit"
use scripting additions


set jsonURL to do shell script "curl --verbose -A UserAgentString -u
2V57JR9HQNAZNZVOW6OZXG:my-password
https://api.fastspring.com/subscriptions?limit=10000";
set temp to jsonURL as text
set OLD_delim to AppleScript's text item delimiters
set AppleScript's text item delimiters to "{\""
set temp to text items of temp
set AppleScript's text item delimiters to "{"
set temp to text items of temp as text
set AppleScript's text item delimiters to ",\""
set temp to text items of temp
set AppleScript's text item delimiters to ","
set temp to text items of temp as text
set AppleScript's text item delimiters to "\":"
set temp to text items of temp
set AppleScript's text item delimiters to ":"
set temp to text items of temp as text
set AppleScript's text item delimiters to OLD_delim
set temp to temp as list
display dialog temp --< Returns
"{action:"subscription.getall",result:"success",page:1,limit:10000,nextPage:null,total:1,subscriptions:["f-DfdENtRvuhBtKJUIA8QQ"]}"
try
        set numbersDict to current application's NSDictionary's
dictionaryWithDictionary:temp
on error errmsg
        display dialog errmsg --<  returns   "*** -[NSDictionary
initWithDictionary:copyItems:]: dictionary argument is not an NSDictionary"
end try
try
        set subscriptionsList to temp's subscriptions as list
end try
subscriptionsList
SCRIPT 2

use AppleScript version "2.4"
use framework "Foundation"
use framework "AppKit"
use scripting additions

set temp to {action:"subscription.getall", result:"success", page:1,
limit:10000, nextPage:null, total:1, subscriptions:["f-DfdENtRvuhBtKJUIA8QQ"]}
as list
try
        set numbersDict to current application's NSDictionary's
dictionaryWithDictionary:temp
on error errmsg
        display dialog errmsg --< no error
end try
try
        set subscriptionsList to numbersDict's subscriptions as list
on error errmsg
        display dialog errmsg --<  returns   "*** -[NSDictionary
initWithDictionary:copyItems:]: dictionary argument is not an NSDictionary"
end try
subscriptionsList --< WORKS! Returns "f-DfdENtRvuhBtKJUIA8QQ"

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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: Tearing my bloody hair out. (From: Jim Skibbie <email@hidden>)

  • Prev by Date: Re: Tearing my bloody hair out.
  • Next by Date: Re: Tearing my bloody hair out.
  • Previous by thread: Re: Tearing my bloody hair out.
  • Next by thread: Re: Tearing my bloody hair out.
  • Index(es):
    • Date
    • Thread