Safer communication between layers using JSON