• 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
Json
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Json


  • Subject: Json
  • From: Jörgen Stahle <email@hidden>
  • Date: Mon, 16 Feb 2015 13:44:58 +0000
  • Thread-topic: Json

Hi, all

This question concerns code for an applescript library once published by Shane Stanley i Macscripter’s forums so it is mainly directed to him – but of course others ar also welcome to answer!

The library in question, can among other things, be used to export JSON code from applescript.

I want to use that very JSON export function. It works fine, but I have one issue about the JSON output: All slashes in text content will be escaped

So for example an ftp uri will be written:
ftp:\/\/ftp.host.se

What i want is just:
ftp://ftp.host.se

Of course I can have a simple search & replace handle to take care if that – but can I instead tweak the Cocoa-related parts of the JSON export handler? I guess that would make the function faster. I know almost nothing about Cocoa. So, can you help me?

The handler I refer to is this:


-- pass a string, list, record or number, and either a path to save the result to, or missing value to have it returned as text
on convertASToJSON:someASThing saveTo:posixPath
--convert to JSON data
set {theData, theError} to current application's NSJSONSerialization's dataWithJSONObject:someASThing options:0 |error|:(reference)
if theData is missing value then error (theError's localizedDescription() as text) number -10000
if posixPath is missing value then -- return string
-- convert data to a UTF8 string
set someString to current application's NSString's alloc()'s initWithData:theData encoding:(current application's NSUTF8StringEncoding)
return someString as text
else
-- write data to file
theData's writeToFile:posixPath atomically:true
return result as boolean -- returns false if save failed
end if
end convertASToJSON:saveTo:

 _______________________________________________
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

  • Follow-Ups:
    • Re: Json
      • From: Emmanuel LEVY <email@hidden>
    • Re: Json
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: Applescript Studio?
  • Next by Date: Re: Applescript Studio?
  • Previous by thread: Re: Applescript Studio?
  • Next by thread: Re: Json
  • Index(es):
    • Date
    • Thread