made $ref a JsonReference
adapted code to handle $ref, not as a string, but a JsonReference