1

I have multiple json files with format like this:

{
    "title" : "abc",
    "desc" : "pqr",
    "img" : "mno",
     "isExpertApproved" : "true"
  }

I just want to add one button in my website where I can upload the file and without storing it anywhere I want to read the data of that file and I also want to store that data into database using javascript.

Is there any way for this? Thank you in advance.

ravi_s
  • 145
  • 2
  • 7
  • 1
    Try out the [FileReader](https://developer.mozilla.org/en/docs/Web/API/FileReader) object. It will save you having to upload the file – Rory McCrossan Jun 22 '16 at 10:17
  • you can find you Answer here [How to read an external local JSON file in Javascript](http://stackoverflow.com/questions/19706046/how-to-read-an-external-local-json-file-in-javascript) – eGhoul Jun 22 '16 at 10:17
  • What database-system do you use? You can't access server-based databases with only client-side javascript – Marcus Jun 22 '16 at 10:17
  • I am using DynamoDB – ravi_s Jun 22 '16 at 10:21

1 Answers1

1

index.html

<div class='wrapper'>
    <p>JSON will be received in 3 seconds</p>
    <ul id='post'></ul>
</div>

external.js

new Request.JSON({
    url: '/echo/json/',
    data: {
        json: JSON.encode({
            text: 'some text',
            array: [1, 2, 'three'],
            object: {
                par1: 'another text',
                par2: [3, 2, 'one'],
                par3: {}
            }
        }),
        delay: 3
    },
    onSuccess: function(response) {
        show_response(response, $('post'));
    }
}).send();

show_response = function(obj, result) {
    $H(obj).each(function(v, k) {
        new Element('li', {
            text: k + ': ' + v
        }).inject(result);
    });
    result.highlight();
};

css

body {
    font-family: Helvetica, Sans, Arial;
}
p, ul {
    padding: 10px;
}
ul {
    margin: 5px;
    border: 2px dashed #999;
}

Click here demo