javascript - How to decode my json string that should be a image url -
i have json file contains images url, guess that's url, looks this: ivborw0kggoaaaansuheugaaadyaaaazcamaaadrvgtcaaaabgdbtueaalgpc/xhbqaaacbjsfjnaab6jgaagiqaapoaaaca6aaadtaaaopgaaa6maaaf3ccule8aaaa81bmveuaaad///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8aaabyfpd3aaaat3rstlmadgst6+qksgbqvqq+h9wctoejfpb6f0imw05ggebhxe1zyuyql6ag3/az9dz9rqedtxlepw+v2ggz8+iapcm+g+zxldximrgpiqiwky4i7fbkmgaaaafis0deaigfhugaaaajcehzcwaacxiaaassadldfvwaaaeusurbvejh7dpzusjaeaxqbkxaqubqqqfcfxhfd4piduj9/7/bqipmqpzunrlvd2rovfdxdvfoekmaikkzw5xeaxjnk7mzvtotdqovyqidowsripkzjagsovdjnk7+3rzpervrnsdxfsvz44rjgls8c1aom5eqocsxpcrkralwf63cnk2kesry2sqxjzi5jhp3pov3xov1fkw7wgjfua6ulyjhlai8kfidt7rmvcmkfff1zdvzili1hqkp5x48bdr5ra6okzsygavw2bqwpiobwcapbqhbo7id7plyhtbw2z6azy46omsrvo+bk9n4dxyoxgg9eqlcvepu9q1we6ef3d8aj0/pvim0vuvlfwi/ev96n8dix6d/gq/vdhxq/iqcru90rd5vahp/3y57tw84cg6xg3b41waaaabjru5erkjggg==
so based on this, how understand , image represents? thanks.
it's png file encoded in base64. can use data uri display in html <img>
tag:
const imagebase64 = 'ivborw0kggoaaaansuheugaaadyaaaazcamaaadrvgtcaaaabgdbtueaalgpc/xhbqaaacbjsfjnaab6jgaagiqaapoaaaca6aaadtaaaopgaaa6maaaf3ccule8aaaa81bmveuaaad///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8aaabyfpd3aaaat3rstlmadgst6+qksgbqvqq+h9wctoejfpb6f0imw05ggebhxe1zyuyql6ag3/az9dz9rqedtxlepw+v2ggz8+iapcm+g+zxldximrgpiqiwky4i7fbkmgaaaafis0deaigfhugaaaajcehzcwaacxiaaassadldfvwaaaeusurbvejh7dpzusjaeaxqbkxaqubqqqfcfxhfd4piduj9/7/bqipmqpzunrlvd2rovfdxdvfoekmaikkzw5xeaxjnk7mzvtotdqovyqidowsripkzjagsovdjnk7+3rzpervrnsdxfsvz44rjgls8c1aom5eqocsxpcrkralwf63cnk2kesry2sqxjzi5jhp3pov3xov1fkw7wgjfua6ulyjhlai8kfidt7rmvcmkfff1zdvzili1hqkp5x48bdr5ra6okzsygavw2bqwpiobwcapbqhbo7id7plyhtbw2z6azy46omsrvo+bk9n4dxyoxgg9eqlcvepu9q1we6ef3d8aj0/pvim0vuvlfwi/ev96n8dix6d/gq/vdhxq/iqcru90rd5vahp/3y57tw84cg6xg3b41waaaabjru5erkjggg=='; const imageurl = 'data:image/png;base64,' + imagebase64; document.queryselector('img').src = imageurl;
body { background: black; }
<img>
the image white , has transparent background, changed page background black make image visible.
if want decode string, can use atob()
function:
const imagebase64 = 'ivborw0kggoaaaansuheugaaadyaaaazcamaaadrvgtcaaaabgdbtueaalgpc/xhbqaaacbjsfjnaab6jgaagiqaapoaaaca6aaadtaaaopgaaa6maaaf3ccule8aaaa81bmveuaaad///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8aaabyfpd3aaaat3rstlmadgst6+qksgbqvqq+h9wctoejfpb6f0imw05ggebhxe1zyuyql6ag3/az9dz9rqedtxlepw+v2ggz8+iapcm+g+zxldximrgpiqiwky4i7fbkmgaaaafis0deaigfhugaaaajcehzcwaacxiaaassadldfvwaaaeusurbvejh7dpzusjaeaxqbkxaqubqqqfcfxhfd4piduj9/7/bqipmqpzunrlvd2rovfdxdvfoekmaikkzw5xeaxjnk7mzvtotdqovyqidowsripkzjagsovdjnk7+3rzpervrnsdxfsvz44rjgls8c1aom5eqocsxpcrkralwf63cnk2kesry2sqxjzi5jhp3pov3xov1fkw7wgjfua6ulyjhlai8kfidt7rmvcmkfff1zdvzili1hqkp5x48bdr5ra6okzsygavw2bqwpiobwcapbqhbo7id7plyhtbw2z6azy46omsrvo+bk9n4dxyoxgg9eqlcvepu9q1we6ef3d8aj0/pvim0vuvlfwi/ev96n8dix6d/gq/vdhxq/iqcru90rd5vahp/3y57tw84cg6xg3b41waaaabjru5erkjggg=='; document.body.textcontent = atob(imagebase64);
Comments
Post a Comment