Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6015

Printing valid JSON with a Swift script

$
0
0

I am attempting to print out in the command line the contents of a variable that holds a JSON object, like in the code:

#! /usr/bin/swiftimport Glibcimport Foundationlet albert_op = ProcessInfo.processInfo.environment["ALBERT_OP"]!if albert_op == "METADATA" {    let metadata = [        ["iid": "org.albert.extension.external/v2.0","name": "Tomboy","version": "0.1","author": "Will Timpson","dependencies": ["tomboy", "python-pydbus"],"trigger": "tb "]    ]    print(metadata))}exit(0)

However, that prints out:

[["trigger": "tb ", "name": "Tomboy", "iid": "org.albert.extension.external/v2.0", "dependencies": ["tomboy", "python-pydbus"], "version": "0.1", "author": "Will Timpson"]]

Which is not valid, I was expecting something like:

{"version": "0.1", "author": "Will Timpson", "iid": "org.albert.extension.external/v2.0", "trigger": "tb ", "dependencies": ["tomboy", "python-pydbus"], "name": "Tomboy"}
  • How to achieve the proper result?

Viewing all articles
Browse latest Browse all 6015

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>