0

I have a sample JSON:

{
    "userUuid": "ea02b5b7-2a5d-40b6-8edf-fa2ae1e204dc",
    "userJson": {
        "generalUser": {
            "country": "United States",
            "customer": "Test",
            "state": "",
            "Id": "a1",
            "time": ":"
        },
        "emPass": {
            "version": "s2.2.2",
            "sn": "a",
            "displayScreen": "0"
        },
        "additionalNotes": ""
    },
    "createdBy": 805
}

I want to convert this JSON in proper formatted image before storing it as a byte array.

Sample image example:

enter image description here

NOTE: The above image is just an example. The actual image should have data from sample JSON.

Is there any easy way to do that or Is it better to do that conversion at client side?

halfer
  • 19,824
  • 17
  • 99
  • 186
sjain
  • 23,126
  • 28
  • 107
  • 185
  • May I ask why you want to do this? This seems an extremely counterintuitive desire – General_Twyckenham Dec 08 '17 at 16:01
  • @General_Twyckenham- On client side, I want to give a button and on click of that button I want to download this JSON data in PDF file. On Server side, I want to store the JSON data as a byte array. So I don't know whether it is best to convert JSON to proper html data at client side or server side. – sjain Dec 08 '17 at 16:08
  • 1
    Your title says "HTML Image" (whatever that means), your question text says "proper formatted image" (whatever that means), and your comment says "PDF file". You'll need to be more specific about what you want, to get an answer and avoid downvotes. – slim Dec 08 '17 at 16:13
  • @MyGod you need to think less about **implementation** and more about what you actually want to do. Decide what the goal is (e.g. enable users to download a PDF of data) then determine the best way to do that. You don't _want_ to store the JSON data as a byte array, you _want_ to store data in a way that makes sense – General_Twyckenham Dec 08 '17 at 16:16
  • @slim- my title, my question text and my comment are all saying same thing- “JSON to proper formatted html image downloadable as pdf file.” – sjain Dec 08 '17 at 18:04
  • @General_Twyckenham- yes, I want to store data in a bytea column. That data can be a json that directly converted into bytea or may be that data can be a json that first converts into proper html image and then into bytea. That we need to decide. But ya column should be a bytea in any case. – sjain Dec 08 '17 at 18:11

0 Answers0