AnsweredAssumed Answered

UniqueValueRenderer on two ShortInteger fields doesn't deserialize from json correctly

Question asked by kirkKuykendall on Nov 20, 2018

I have a featureclass with two ShortInteger fields that I tried to symbolize with a UniqueValueRenderer that was deserialized from json (Renderer.FromJson).  (v 100.4)


After seeing the wrong symbols on the map, I discovered the values were System.String types.

I replaced the values with Int16s and it displayed correctly.

private void UvrBugWorkaround(UniqueValueRenderer uvr)
        // when a uvr that has multiple short integer fields is deserialized from json,
        // the resulting UVR has string values in it, causing it not to behave as expected
        // (all features get displayed with the "other" symbol)
        // Here is a workaround that replaces the string values with short values.
        foreach(var v in uvr.UniqueValues)
            List<short> vals = new List<short>();
            foreach(var v2 in v.Values)
                short i;
                short.TryParse(v2.ToString(), out i);
                Debug.Print(v2.ToString() + ": " + v2.GetType().ToString());
            foreach (var newval in vals)
        // notice the json remains unchanged ... perhaps the real bug is in the deserializer?
        // (the layer now draws correctly)
    catch (Exception ex)