Added writeToJson function

Added write to json function. Takes a time section and inserts it to
the json file.
Added filter function

Added the filter function.
Some cleaning and function renaming