Exemplo n.º 1
0
        public static PSObject Deserialize(string json)
        {
            if (String.IsNullOrEmpty(json))
            {
                return(null);
            }

            Hashtable parameters = new Hashtable();

            parameters.Add(Constants.PsCommandParamInputObject, json);
            var result = PowerShellJsonConverter.InvokeScript(Constants.PsCommandConvertFromJson, parameters);

            if (result.Count != 1)
            {
                return(null);
            }

            //count == 1. return the first psobject
            return(result[0]);
        }
Exemplo n.º 2
0
        public static string Serialize(object inputObject)
        {
            if (inputObject == null)
            {
                return(null);
            }

            Hashtable parameters = new Hashtable();

            parameters.Add(Constants.PsCommandParamInputObject, inputObject);
            parameters.Add(Constants.PsCommandParamDepth, Constants.PsCommandValueDepth);
            var result = PowerShellJsonConverter.InvokeScript(Constants.PsCommandConvertToJson, parameters);

            if (result.Count != 1)
            {
                return(null);
            }

            return(result[0].ToString());
        }