Using json to serialize object