public JToken JTokenTranserializerImpl(object source) { var jtokenEmitter = new JTokenEmitter(); ValueSerialier.SerializeValue(jtokenEmitter, source, source?.GetType() ?? typeof(object)); return(jtokenEmitter.Root); }
public object Search(string expression, object json) { var jtokenEmitter = new JTokenEmitter(); _serializers.ValueSerialier.SerializeValue(jtokenEmitter, json, json?.GetType() ?? typeof(object)); var transformOutput = _jmespath.Transform(jtokenEmitter.Root, expression); using (var stringWriter = new StringWriter()) { using (var jsonWriter = new JsonTextWriter(stringWriter) { CloseOutput = false }) { transformOutput.WriteTo(jsonWriter); } var jsonText = stringWriter.GetStringBuilder().ToString(); return(_serializers.YamlDeserializer.Deserialize <object>(jsonText)); } }