Re: Tearing my bloody hair out.
Re: Tearing my bloody hair out.
- Subject: Re: Tearing my bloody hair out.
- From: Brian Christmas <email@hidden>
- Date: Sat, 16 Sep 2017 21:05:58 +1000
Sorry about all this noise!
I’ve just realized something, but I don’t know the answer to my understanding.
When I posted the below Script 2, I’d added 'as list’ to the end of…..
set temp to {action:"subscription.getall", result:"success", page:1,
limit:10000, nextPage:null, total:1, subscriptions:["f-DfdENtRvuhBtKJUIA8QQ"]}
as list
THIS ACTUALLY FAILS. Which leads me to understand without the ‘as list', I’ve
actually got an applescript Record in Script 2 (please correct me if I’m wrong)
The Record WORKS! (bofere I added ‘as list’)
HOWEVER, in Script 1, the list is actually text, NOT A RECORD, and fails.
Problem is, even after reading Shanes Explored, I can’t find a way of
converting the text to a Record.
I’ve Googled, found nothing.
How can I change the text to an Applescript Record? I HAVE to change the
original to text to apply Delimiters, to get rid of the quotations. The
information is there, just in the wrong format.
OR, is there an easier way?
Regards
Santa
>
> 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
> <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"
> _._,_._,_
> Groups.io Links:
> You receive all messages sent to this group.
>
> View/Reply Online (#55)
> <https://apple-dev.groups.io/g/applescript/message/55> | Reply To Group
> <mailto:email@hidden?subject=Re: Re: [applescript] Tearing my bloody hair out.>
> | Reply To Sender
> <mailto:email@hidden?subject=Private: Re: Re: [applescript] Tearing my bloody hair out.>
> | Mute This Topic <https://groups.io/mt/6016735/360169> | New Topic
> <https://apple-dev.groups.io/g/applescript/post>
> Change Your Subscription
> <https://apple-dev.groups.io/g/applescript/editsub/360169>
> Group Home <https://apple-dev.groups.io/g/applescript>
> Contact Group Owner <mailto:email@hidden>
> Terms Of Service <https://groups.io/static/tos>
> Unsubscribe From This Group
> <https://apple-dev.groups.io/g/applescript/leave/695760/955856845/xyzzy>
> _._,_._,_
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