• 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: Change a aJSON list to an Applescript list?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Change a aJSON list to an Applescript list?


  • Subject: Re: Change a aJSON list to an Applescript list?
  • From: Brian Christmas <email@hidden>
  • Date: Sun, 10 Sep 2017 11:13:53 +1000

G’day all.

Thank you Nigel.

I have the code in place, but have to wait a while before I can test it.

FastSpring have given me code to use for a pop-up store front, but it’s for an
https address, and my site is actually not secure yet.

So, I’ve had to apply for a top level security certificate, which could take a
week, before I can apply it, and actually run tests to build up a list of
temporary test transactions.

So, at the moment, the Json code returns {}. Patience, patience.

A brief question. If the dim, dark recesses of my scattered memory recall
correctly, this code is the fastest option when evaluating if an item is in a
list of 10,000 pre-determined codes, created in part with a seeded random
generator?

>  set subscriptionsList to (jsonObject's objectForKey:("subscriptions")) as
> list
 set serialNumberIsInList to (aSerialNumber is in subscriptionsList)

True?

Regards

Santa

> On 9 Sep 2017, at 6:53 pm, Nigel Garvey <email@hidden> wrote:
>
> Brian Christmas wrote on Sat, 9 Sep 2017 02:41:51 +1000:
>
>> … need to check monthly if the serial number for each App is still in
>> FastSprings valid serials active list.
>>
>> This list is downloadable as a JSON file, and I’m trying to work out
> how to
>> interpret that information into an Applescript list.
>>
>> The JSON API is in the form…
>>
>> {
>> "action": "subscription.getall",
>> "result": "success",
>> "nextPage": 3,
>> "subscriptions": [
>>   "khyNPLY3TYiQhBfHyjZINg",
>>   "w46bQ2-gTayzJfFXbV1VWg",
>>   "86cFjtgCRlSmOPbLcX_mCA",
>>   "v0yPCSTLSyarVe9NlNalSA",
>>   "FWhWZ3b6StyfiJ_GnyHswQ",
>>   "A5xx9TF_R26PcCMdagAC8Q",
>>   "pgNumDwTSbaLeNY6FtUF3Q",
>>   "IK2eD1nvSP-L3yilE6K7BQ",
>>   "iZ8qUO-MSwuezTn_elPb3g",
>>   "gLspcP3NRqmdOm615HSTig",
>>   "HYKxh1JfTcyUhTgJxAxfWg",
>>   "1RkJixj_QKOg_c7G_wGIZA",
>>   "LiPzVuKnT2Go1WWteQkZtw",
>>   "V5wXtLilSsWGkMYSiLVy2g",
>>   "MseNZ_LBRu63R84k9knIKg"
>> ]
>> }
>
> That translates to a _record_ which has a list as one of its values.
>
>  use AppleScript version "2.4" -- Mac OS 10.10 (Yosemite) or later.
>  use framework "Foundation"
>
>  set jsonURL to "http://your/url/here"; -- Set as required.
>  set jsonURL to current application's class "NSURL"'s URLWithString:(jsonURL)
>  set jsonData to current application's class "NSData"'s
> dataWithContentsOfURL:(jsonURL)
>  set {jsonObject, theError} to current application's class
> "NSJSONSerialization"'s JSONObjectWithData:(jsonData) options:(0)
> |error|:(reference)
>  if (jsonObject is missing value) then error (theError's
> localizedDescription() as text)
>
>  set aSerialNumber to "w46bQ2-gTayzJfFXbV1VWg" -- Or whatever.
>  -- There are various ways to check if this occurs in the JSON object's
> 'subscriptions' array. For instance:
>  set jsonRecord to jsonObject as record
>  set serialNumberIsInList to (aSerialNumber is in jsonRecord's subscriptions)
>  -- Or:
>  set subscriptionsList to (jsonObject's objectForKey:("subscriptions")) as
> list
>  set serialNumberIsInList to (aSerialNumber is in subscriptionsList)
>  -- Or:
>  set subscriptionsArray to jsonObject's objectForKey:("subscriptions")
>  set serialNumberIsInList to (subscriptionsArray's
> containsObject:(aSerialNumber)) as boolean
>
>
> NG
> _______________________________________________
> 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

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: Change a aJSON list to an Applescript list? (From: "Nigel Garvey" <email@hidden>)

  • Prev by Date: Re: Change a aJSON list to an Applescript list?
  • Next by Date: 2 tricky questions
  • Previous by thread: Re: Change a aJSON list to an Applescript list?
  • Next by thread: Re: Change a aJSON list to an Applescript list?
  • Index(es):
    • Date
    • Thread