You can use pre tag to display formatted json.
const json = {
id: "1",
employee_name: "Tiger Nixon",
employee_salary: "320800",
employee_age: "61",
profile_image: ""
};
document.getElementById("app").innerHTML = JSON.stringify(json, (key, value) => (value || ''), 4).replace(/"([^"]+)":/g, '$1:');
<div><pre id="app"></pre></div>
Answer from Santosh Sagar on Stack OverflowYou can use pre tag to display formatted json.
const json = {
id: "1",
employee_name: "Tiger Nixon",
employee_salary: "320800",
employee_age: "61",
profile_image: ""
};
document.getElementById("app").innerHTML = JSON.stringify(json, (key, value) => (value || ''), 4).replace(/"([^"]+)":/g, '$1:');
<div><pre id="app"></pre></div>
Human.json
The best solution for you problem would be json.human. It converts JSON data in to tabular from which of course is human readable (even for non-technicle people). And the best part is it open-source.
Human.json Git-hub
Converting Json file to a human readable format? - Stack Overflow
FracturedJson - a JSON formatter that produces human-readable but fairly compact output
[Help] How to convert .json files to something readable by a pleb like me
jquery - Convert JSON hash to human readable string - Stack Overflow
Videos
Json is a format which looks like plain text. I guess you know what you are asking. If you need to convert a file containing Json text to a readable format, you need to convert that to an Object and implement toString() method(assuming converting to Java object) to print or write to another file in a much readabe format. You can use any Json API for this, for example Jackson JSON API.
ObjectMapper obj = new ObjectMapper();
T t=obj.readValue(File src, Class<T> valueType)
t.toString(); //this must have been implemented
Found a suitable online JSON formatter by Curious Concept : https://jsonformatter.curiousconcept.com/
You just paste/drop your file inside and click "Process", then download the resulting beautified JSON.
Might not be a proper answer I don't know if online tools may apply, but I've found this, it solved my issue and it can be useful, so I think it's worth mentioning...
ยป npm install json-to-plain-text
Dear programmers of Reddit,
Instagram allows people to download their data as .json files. I need to read the contents of the direct messages .json file for a message I sent to someone many months ago and we text a lot so scrolling will take hours if not a day.
Please teach me. I don't know anything about programming so if there is a way I can convert it to a word or txt file it would be great!
Thanks in advance!
Iterate over the errors and append them to an element.
$("#errors").empty();
$.each(responseJSON.errors, function(key, value) {
$("#errors").append("<div>" + key + " " + value + "</div>");
});
You can iterate over the errors like so:
for (var name in responseJSON.errors) {
var message = responseJSON.errors[name];
}
Not sure how you want to display the error message(s) so I'll leave that up to you. But this should be enough to get the information you want out of your JSON object.