Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Nirmit 24 posts 97 karma points
    Aug 05, 2015 @ 05:00

    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

  • Thomas Mulder 15 posts 86 karma points
    Apr 13, 2016 @ 16:52
    Thomas Mulder

    Better late than never I guess, but you could try this:

    public static string ResolveVortoValue(this string rawValue, CultureInfo currentCulture)
        VortoValue vortoValue;
            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 ;-)

Please Sign in or register to post replies

Write your reply to: