Using json encoder instead of marshal