Convert json fencing to javascript