preloader
blog-post

REST API To Flatten JSON

Table of Contents

Flatten JSON is an simple REST API which takes a JSON object as input and parses into a key/value string. Here the key will have the full path for the field separated by .(dot). API is built on AWS with Lambda Function(Python), API Gateway, Custom Domain Mapping.

Steps to create the API

  • Create lambda function with the code for required logic. Test and make sure the lambda is working fine.

  • Click on Add trigger, select API Gateway and select create new API option as given below. Make sure to test the API using the right method before heading to next step.

  • To add custom domain api endppoint, create a certifcate for the domain from ACM

  • Attach the custom domain to API gateway using the certificate by navigating to API Gateway > Custom domain names > Create

  • Navigate to Custom domain names and click on API mappings to map the API with a URL path of your preference.

Steps to invoke the API

  • See API details below. You can invoke this service using Postman, Please see below image for an example.
URL https://api.entechlog.com/flatten-json/
Method POST
Content-Type application/json
  • Sample Input

  • Sample output

Notes

  • Currently returns “application/json”, will be enhanced to return “text/plain” also.
  • Disclaimer : This API logs all incoming requests, So please don’t send any confidential information.
  • Service runs on free tier of AWS, So please avoid duplicate calls to keep the service alive.

References

Share this blog:
Comments

Related Articles