OpenSim.Region.ScriptEngine.Shared.Api.LSL_Api.ListToJson C# (CSharp) Method

ListToJson() private method

private ListToJson ( object o ) : OSD
o object
return OSD
        private OSD ListToJson(object o)
        {
            if (o is LSL_Float || o is double)
            {
                double float_val;
                if (o is double)
                    float_val = ((double)o);
                else
                    float_val = ((LSL_Float)o).value;

                return OSD.FromReal(float_val);
            }
            if (o is LSL_Integer || o is int)
            {
                int i;
                if (o is int)
                    i = ((int)o);
                else
                    i = ((LSL_Integer)o).value;

                if (i == 0)
                    return OSD.FromBoolean(false);
                else if (i == 1)
                    return OSD.FromBoolean(true);
                return OSD.FromInteger(i);
            }
            if (o is LSL_Rotation)
                return OSD.FromString(((LSL_Rotation)o).ToString());
            if (o is LSL_Vector)
                return OSD.FromString(((LSL_Vector)o).ToString());
            if (o is LSL_String || o is string)
            {
                string str;
                if (o is string)
                    str = ((string)o);
                else
                    str = ((LSL_String)o).m_string;

                if (str == ScriptBaseClass.JSON_NULL)
                    return new OSD();
                return OSD.FromString(str);
            }
            throw new Exception(ScriptBaseClass.JSON_INVALID);
        }
LSL_Api