extract the common json unmarshalling