javascript - Html5 filereader - read local Json Array file and display only a specific section -


i'm beginner , come form vba excel programming tool. reading excel file, manipulating excel content lot easier in vba web tool filereader , json array.

i have following content in json array file.

[   ["twe",6000,4545.5  ],   ["rw",1000,256.3  ] ] 

i read following html file , display value 253.6

can me.

here html file reader example

<!doctype html> <html>     <head>         <script>                     function handlefileselect()             {                                if (window.file && window.filereader && window.filelist && window.blob) {                  } else {                     alert('the file apis not supported in browser.');                     return;                 }                     input = document.getelementbyid('fileinput');                 if (!input) {                   alert("um, couldn't find fileinput element.");                }                else if (!input.files) {                   alert("this browser doesn't seem support `files` property of file inputs.");                }                else if (!input.files[0]) {                   alert("please select file before clicking 'load'");                               }                else {                   file = input.files[0];                   fr = new filereader();                   fr.onload = receivedtext;                   fr.readastext(file);                }             }              function receivedtext() {                           //result = fr.result;                document.getelementbyid('editor').appendchild(document.createtextnode(fr.result))             }                     </script>     </head>     <body>         <input type="file" id="fileinput"/>         <input type='button' id='btnload' value='load' onclick='handlefileselect();'>         <div id="editor"></div>     </body> </html> 

if text fr.readastext string, can use json.parse() (see: https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/json/parse) convert string json object. can access specific content normal array.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -