0

I have a an JSON file: example_json.json and this file looks like this:

{
    "timeline":
    {
        "headline":"WELCOME",
        "type":"default",
        "text":"People say stuff",
        "startDate":"10/4/2011 15:02:00",
        "date": [
            {
                "startDate":"10/4/2011 15:10:00",
            "endDate":"10/4/2011 15:55:00",
                "headline":"prvo",
                "text":"<p>dddddddddddddddd dd</p>",
                "asset":
                {

                    "caption":"yessss"
                }
            },
            {
                "startDate":"10/4/2011 17:02:00",
                "endDate":"10/4/2011 18:02:00",
                "headline":"drugo da da",
                "text":"<p>In true political fashion, his character rattles off common jargon heard from people running for office.</p>",
                "asset":
                {
                    "media":"http://youtu.be/u4XpeU9erbg",
                    "credit":"",
                    "caption":""
                }
            }
        ]
    }
}

so this is example of json file.

On other side I have this variables:

var place.name;
var zajson;

and: <button>Add to timeline</button>

Now I want when I click on button "add to timeline" to create new 'element' inside "date" with "startDate" to be: curentDateFormat in format month/day/year + zajson

and to add "headline" : place.name

How I can add this variables and create new element inside "date" in example_json.json?

drTesla
  • 31
  • 1
  • 8

1 Answers1

0

You could do this client-side in modern browsers. For example you can use local storage (or cookie or something) to manipulate JSON dynamically and create a file using BlobBuilder.

Example:

window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
var file = new window.BlobBuilder()
approxiblue
  • 6,982
  • 16
  • 51
  • 59
phani
  • 1,134
  • 1
  • 11
  • 24