Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Google Cloud Function To Convert Property Lists To JSON Documents

I’ve written a lot of little scripts to convert files or types from one format to another, over the years. It’s easier to import something that can do the work for you and just use a Lambda or a Google Cloud Function that you call from other tools. This is the microservice way.

So here’s a little python Google Cloud Function that converts a property list to a JSON document:


import json

def property_list_to_json(event, context):

  # Get the property list from the event.
  property_list = event['body']

  # Convert the property list to a JSON document.
  json_data = json.dumps(property_list)

  # Return the JSON document.
  return json_data

To use the function, first create a Google Cloud Function that uses the property_list_to_json() function from the Google Cloud Console or the gcloud CLI. Once you have the URL, simply call it with a POST to the function’s URL. The request body should contain the property list to convert. The response body will contain the JSON document. So to convert the property list my_properties.properties, you would use the following command:

curl -X POST -H 'Content-Type: application/json' -d @my_properties.properties 

Obviously, if there’s any authentication or token to authorize access to the function, that will need to be added to the curl as well.

The post Google Cloud Function To Convert Property Lists To JSON Documents appeared first on krypted.



This post first appeared on Krypted.com | Tiny Deathstars Of Foulness, please read the originial post: here

Share the post

Google Cloud Function To Convert Property Lists To JSON Documents

×

Subscribe to Krypted.com | Tiny Deathstars Of Foulness

Get updates delivered right to your inbox!

Thank you for your subscription

×