Home » Java » How to decompress json data request at server side?

How to decompress json data request at server side?

Posted by: admin April 25, 2018 Leave a comment

Questions:

I have a python client side code which hits an URL with compressed JSON data.

I want to decompress and print the JSON data (that i got from client request) in java.

Client code:

  #!/usr/bin/python

  import sys, getopt
  import requests
  import json
  from zlib import compress

  s = requests.session()
  url = "http://1.1.1.1:8080/eventfull/send/data/"
  payload = dict(
    username="test",
    password="test123",
    emailid=sys.argv[1],
    campaignfrom="info@newsletter.x.com",
    send_id="1234",
    istest="1",
    render_id=sys.argv[2],
    subject="Eventfull :: Services HeartBeat",
    htmlbody="<html><body><p>Hi Team,</p></br></br><p>This is a Test Campaign to ensure eventfull calls are working as expected</p></br></br><p>Thanks,</p><br><p>Tech Team</p></body></html>",
    textbody="Testing"
  )
  json_string = json.dumps(payload)
  compressed = compress(json_string,9)
  response = s.post(url, data=compressed )

  print response.status_code
  print response.content
Answers: