Hi,
Is there any simple way to get vorto value from a Json string?
The scenario I have is, I am using vorto with ArcheType, and in my view, I am getting ArcheTypeModel. now I can get vorto value as string from ArcheTypeModel, but cant find any way to convert this string into Vorto Model (or to fetch Vorto value out of that json string).
Better late than never I guess, but you could try this:
public static string ResolveVortoValue(this string rawValue, CultureInfo currentCulture)
{
VortoValue vortoValue;
try
{
vortoValue = JsonConvert.DeserializeObject<VortoValue>(rawValue);
}
catch (Exception)
{
//wasn't valid json for VortoValue
return rawValue;
}
if (vortoValue == null) return rawValue;
object resolvedValue;
if (!vortoValue.Values.TryGetValue(currentCulture.Name, out resolvedValue)) return rawValue; //no value for currentCulture, also possible to check for other cultures if you want
return resolvedValue.ToString();
}
EDIT: maybe I should've mentioned that I haven't tested this code, but it should get you going if it wouldn't work after copy-paste ;-)
Get Vorto Value from string
Hi, Is there any simple way to get vorto value from a Json string? The scenario I have is, I am using vorto with ArcheType, and in my view, I am getting ArcheTypeModel. now I can get vorto value as string from ArcheTypeModel, but cant find any way to convert this string into Vorto Model (or to fetch Vorto value out of that json string).
Thanks, Nirmit
Better late than never I guess, but you could try this:
EDIT: maybe I should've mentioned that I haven't tested this code, but it should get you going if it wouldn't work after copy-paste ;-)
is working on a reply...