public void TestGetNextPropertyIndex() { string TestJSONString = "{ \"Property\" : 1.0, \"Property2\" : 1 }"; var result = ElementsFinder.GetNextPropertyIndex(TestJSONString, 0); Assert.Equal(2, result); }
public IDecompositor Go() { int strIndex = 0; if (!string.IsNullOrEmpty(JSONInput)) { if (ElementsFinder.StartAndStopExist(JSONInput)) { for (;;) { var index = ElementsFinder.GetNextPropertyIndex(JSONInput, strIndex); if (index == -1) { IsComplited = false; break; } var NextPropertyFragment = ElementsFinder.GetPropertyFragment(JSONInput, index); if (!string.IsNullOrEmpty(NextPropertyFragment)) { strIndex = index + NextPropertyFragment.Length; } else { IsComplited = false; break; } var PropertyName = ElementsFinder.GetFragmentName(NextPropertyFragment); var PropertyDataType = ElementsFinder.GetFragmentDataType(NextPropertyFragment); var PropertyType = ElementsFinder.GetFragmentType(NextPropertyFragment); var ProperyValue = ElementsFinder.GetFragmentValue(NextPropertyFragment); _Parts.Add(ClassPart.Create(PropertyType, PropertyDataType, NextPropertyFragment, PropertyName, ProperyValue)); } } } else { IsComplited = false; } return(this); }
public void TestGetPropertyFragment() { string TestJSONString = "{ \"Property\" : 1.0, \"Property2\" : 1 }"; var result1 = ElementsFinder.GetPropertyFragment(TestJSONString, ElementsFinder.GetNextPropertyIndex(TestJSONString, 0)); Assert.Equal("\"Property\" : 1.0", result1); }