Added try-catch to WriteJson to catch LazyInitializationException