/// <summary> /// Read <see cref="IJsonValue"/> to a string, the input JsonValue should be a string, /// otherwise, throw unexpected value kind exception. /// </summary> /// <param name="jsonValue">The <see cref="IJsonValue"/> to parse from.</param> /// <param name="jsonPath">The JSON path for current JSON node which owns this value.</param> /// <returns>The string.</returns> public static string ReadPrimitiveString(this IJsonValue jsonValue, IJsonPath jsonPath) { // EdmUtil.CheckArgumentNull(jsonValue, "jsonValue"); // EdmUtil.CheckArgumentNull(jsonPath, "jsonPath"); jsonValue.ValidateValueKind(JsonValueKind.Primitive, jsonPath); JsonPrimitiveValue primitiveValue = (JsonPrimitiveValue)jsonValue; if (primitiveValue.Value == null) { return(null); } if (primitiveValue.Value.GetType() == typeof(string)) { return((string)primitiveValue.Value); } throw new Exception(/*Strings.JsonReader_CannotReadValueAsType(primitiveValue.Value, jsonPath.Path, "String")*/); }