NDB.Node.Parse C# (CSharp) Method

Parse() public static method

public static Parse ( string json ) : Node
json string
return Node
        public static Node Parse(string json)
        {
            string tempStr= json.Split(',')[0];
            string docId = tempStr.Split(':')[1];
            Node newNode = new Node(docId);

            json = json.Split('[')[1];
            json = json.Split(']')[0];

            var nodeList = json.Split('{');
            var versionList = new Dictionary<string,Dictionary<string,string>>();

            foreach (string node in nodeList)
            {
                if (node != "")
                {
                    var propertyList = node.Split(',');

                    var propList = new Dictionary<string, string>();

                    foreach (string property in propertyList)
                    {
                        string propStr = property.Split('}')[0];

                        string propName = propStr.Split(':')[0];
                        string propValue = propStr.Split(':')[1];

                        propList.Add(propName, propValue);
                    }

                    versionList.Add(propList["version"], propList);
                    newNode.addVersion(propList["version"],propList["sequence"],propList["rev_id"]);
                }
            }

            return newNode;
        }

Usage Example

コード例 #1
0
ファイル: NouchDB.cs プロジェクト: Kirosoft/NouchDB
        public Node GetDocInfo(string docId, string rev_id = "")
        {
            Node docInfo = null;

            string docInfoString = docStore.Get(ReadOptions.Default, docId).ToString();

            if (docInfoString != null)
            {
                docInfo = Node.Parse(docInfoString);
            }

            return(docInfo);
        }
All Usage Examples Of NDB.Node::Parse