modified a function to allow adding json data from string or file