/// <summary> /// Sets the stream from which to get the json string to show. /// </summary> /// <param name="stream"></param> public void SetJsonSource(Stream stream) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } JTokenRoot jsonEditorItem; try { jsonEditorItem = new JTokenRoot(stream); } catch (Exception exception) { throw new WrongJsonStreamException("Stream could not be parsed from json", exception); } jsonTreeView.Nodes.Clear(); jsonTreeView.Nodes.Add(JsonTreeNodeFactory.Create(jsonEditorItem.JTokenValue, 2)); jsonTreeView.Nodes .Cast <TreeNode>() .ForEach(n => n.Expand()); }