I want that in the following method the else if block of code to be present based on the attrNameListCurrent.Length. In other words if attrNameListCurrent.Length=2 I need to have only if (attrNameListCurrent[0] != attrNameListPrevious[0]) and
else
{
result += AddItem(attrList[i]);
if ( i == attrList.Count - 1)
{
result = result.TrimEnd(',');
result += CloseObject(attrList[i]); ///
}
part of code.
If attrNameListCurrent.Length=3 I want to add else if (attrNameListCurrent[1] != attrNameListPrevious[1]) block of code between them
if attrNameListCurrent.Length=4 I want to add else if (attrNameListCurrent[2] != attrNameListPrevious[2]) block of code and so forth.
Is any way to do this programmatically? Please any suggestion would be appreciated.
My method:
public static string ReadRsdToJson(List<AttributeProperties> attrList)
{
string result = "{";
bool createNew = true;
string attrName = string.Empty;
string[] attrNameListCurrent;
string[] attrNameListPrevious;
if (attrList.Count == 0) result = "{}"; // Test -1; the list is empty
for (var i = 0; i < attrList.Count; i++)
{
if (attrList[i].XPath != null)
{
if (i == 0) result += CreateNewObject(attrList[i]);
if (i == 0 && i == attrList.Count - 1) result += CloseObject(attrList[i]);
attrNameListCurrent = attrList[i].XPath.Split('/');
if (i != 0)
{
attrNameListPrevious = attrList[i - 1].XPath.Split('/');
if (attrNameListCurrent[0] != attrNameListPrevious[0])
{
result = result.TrimEnd(','); //close the previous object
if (attrNameListCurrent[0] != attrList[i-1].XPath.Split('/')[0]) result += CloseObject(attrList[i-1]);//create new object
result += CreateNewObject(attrList[i]);
if (i==attrList.Count-1)
{
result = result.TrimEnd(',');
result += CloseObject(attrList[i]); ///
}
}
else if (attrNameListCurrent[1] != attrNameListPrevious[1])
{
result = result.TrimEnd(',');
if (attrNameListCurrent[1] != attrList[i - 1].XPath.Split('/')[1]) result += CloseNestedNthObject(attrList[i-1], 1);
result += CreateNestedNthElement(attrList[i], 1);
if (i == attrList.Count - 1)
{
result = result.TrimEnd(',');
result += CloseObject(attrList[i]);
}
}
else if (attrNameListCurrent[2] != attrNameListPrevious[2])
{
result = result.TrimEnd(',');
if (attrNameListCurrent[2] != attrList[i - 1].XPath.Split('/')[2]) result += CloseNestedNthObject(attrList[i-1], 2);
result += CreateNestedNthElement(attrList[i], 2);
if (i == attrList.Count - 1)
{
result = result.TrimEnd(',');
result += CloseObject(attrList[i]);
}
}
else if (attrNameListCurrent[3] != attrNameListPrevious[3])
{
result = result.TrimEnd(',');
if (attrNameListCurrent[3] != attrList[i - 1].XPath.Split('/')[3]) result += CloseNestedNthObject(attrList[i-1], 3);
result += CreateNestedNthElement(attrList[i], 3);
if (i == attrList.Count - 1)
{
result = result.TrimEnd(',');
result += CloseObject(attrList[i]);
}
}
else
{
result += AddItem(attrList[i]);
if ( i == attrList.Count - 1)
{
result = result.TrimEnd(',');
result += CloseObject(attrList[i]); ///
}
}
}
}
else
{
if (attrList[i].Type == "integer" || attrList[i].Aggregate != null)
{
result += '"' + attrList[i].Name + '"' + ": " + attrList[i].Value + ',';
}
else
{
result += '"' + attrList[i].Name + '"' + ": " + '"' + attrList[i].Value + '"' + ',';
}
}
if (i == attrList.Count - 1)
{
result = result.TrimEnd(',');
result += '}';
}
}
return result;
}
Have you though about using a switch statement? It sounds like it might be what you need if i am understanding correctly.
Something like
switch (attrNameListCurrent.Length)
{
case 1:
#if length is 1 do thing
break;
case 2:
#if length is 2 do thing
break;
case 3:
#if length is 3 do thing
break;
}
If what you are trying to do is build a tree from a list of paths + values and then serialize that to JSON it would be easier to build the tree and then serialize it. Suppose you have a TreeNode class that stores a list of child TreeNodes and a Value. Suppose it supports an indexer so you can access the child nodes using []. Then you could do something like this:
public static string ReadRsdToJson(List<AttributeProperties> attrList)
{
var root = new TreeNode();
foreach (var attr in attrList)
{
var pathElements = attr.XPath.Split('/');
var current = root;
// Scan down the path following or building the tree at each step
foreach (var pathElement in pathElements)
{
if (current.ContainsKey(pathElement))
current = current[pathElement];
else
{
var newChild = new TreeNode(pathElement);
current.AddChild(newChild);
current = newChild;
}
}
// current is now the node at leaf of the tree that you want
current.Value = attr.Value;
}
// And now you have built a tree you can serialize that to Json
// If you must write your own serializer instead of using JSON.NET
// consider using string.Join(",",...) instead of trimming commas
}
It doesn't match your code exactly but your code was really too long and complicated for a SO question. Best to simplify it down to the bare essence of what you are asking.
Related
I am trying to write a markup editor in c#, part of is is to detect which tags are affecting where the caret currently is.
Examples:
<b>Tes|ting</b><u><i>Testing</i>Testing</u> (caret '|' at index 6)
Answer: [b]
<b>Testing<u><i>Test|ing</i>Tes</b>ting</u> (caret '|' at index 20)
Answer: [b, u, i]
Here is the code I have currently, inside "GetTags()" I split the string into 2 queues representing what tags are in front and behind where the caret is. I played around with ways to pop the elements from both queues to try to solve the problem but I keep getting wrong results. I think im on the right track creating 2 data structures but I don't know if Queue<> is what I need.
public class Tag
{
public enum TagType
{
bold,
italic,
underline,
}
public TagType type;
public bool opening;
public Tag(TagType type, bool opening)
{
this.type = type;
this.opening = opening;
}
public static Tag GetTagFromString(string str)
{
switch (str)
{
case "<b>": return new Tag(TagType.bold, true);
case "</b>": return new Tag(TagType.bold, false);
case "<i>": return new Tag(TagType.italic, true);
case "</i>": return new Tag(TagType.italic, false);
case "<u>": return new Tag(TagType.underline, true);
case "</u>": return new Tag(TagType.underline, false);
}
return null;
}
public static List<TagType> GetTags(string str, int index)
{
Queue<Tag> backQueue = new Queue<Tag>();
Queue<Tag> forwardQueue = new Queue<Tag>();
// populate the back queue
int i = index;
while (true)
{
int lastOpening = str.LastIndexOf('<', i);
int lastClosing = str.LastIndexOf('>', i);
if (lastOpening != -1 && lastClosing != -1)
{
string tagStr = str.Substring(lastOpening, lastClosing - lastOpening + 1);
Tag tag = GetTagFromString(tagStr);
backQueue.Enqueue(tag);
i = lastOpening - 1;
if (i < 0)
break;
}
else
break;
}
// populate the front stack
i = index;
while (true)
{
int nextOpening = str.IndexOf('<', i);
int nextClosing = str.IndexOf('>', i);
if (nextOpening != -1 && nextClosing != -1)
{
string tagStr = str.Substring(nextOpening, nextClosing - nextOpening + 1);
Tag tag = GetTagFromString(tagStr);
forwardQueue.Enqueue(tag);
i = nextClosing + 1;
}
else
break;
}
List<TagType> tags = new List<TagType>();
// populate 'tags' list with the tags affecting the index here
return tags;
}
public override string ToString()
{
string str = "<";
if (!opening)
str += "/";
switch (type)
{
case TagType.bold:
str += "b";
break;
case TagType.italic:
str += "i";
break;
case TagType.underline:
str += "u";
break;
}
str += ">";
return str;
}
}
Would love any input on how I could solve this and would greatly appreciate any issues anyone has with the code that I've provided.
When tokenizing in superpower, how to match a string only if it is the first thing in a line (note: this is a different question than this one) ?
For example, assume I have a language with only the following 4 characters (' ', ':', 'X', 'Y'), each of which is a token. There is also a 'Header' token to capture cases of the following regex pattern /^[XY]+:/ (any number of Xs and Ys followed by a colon, only if they start the line).
Here is a quick class for testing (the 4th test-case fails):
using System;
using Superpower;
using Superpower.Parsers;
using Superpower.Tokenizers;
public enum Tokens { Space, Colon, Header, X, Y }
public class XYTokenizer
{
static void Main(string[] args)
{
Test("X", Tokens.X);
Test("XY", Tokens.X, Tokens.Y);
Test("X Y:", Tokens.X, Tokens.Space, Tokens.Y, Tokens.Colon);
Test("X: X", Tokens.Header, Tokens.Space, Tokens.X);
}
public static readonly Tokenizer<Tokens> tokenizer = new TokenizerBuilder<Tokens>()
.Match(Character.EqualTo('X'), Tokens.X)
.Match(Character.EqualTo('Y'), Tokens.Y)
.Match(Character.EqualTo(':'), Tokens.Colon)
.Match(Character.EqualTo(' '), Tokens.Space)
.Build();
static void Test(string input, params Tokens[] expected)
{
var tokens = tokenizer.Tokenize(input);
var i = 0;
foreach (var t in tokens)
{
if (t.Kind != expected[i])
{
Console.WriteLine("tokens[" + i + "] was Tokens." + t.Kind
+ " not Tokens." + expected[i] + " for '" + input + "'");
return;
}
i++;
}
Console.WriteLine("OK");
}
}
I came up with a custom Tokenizer based on the example found here. I added comments throughout the code so you can follow what's happening.
public class MyTokenizer : Tokenizer<Tokens>
{
protected override IEnumerable<Result<Tokens>> Tokenize(TextSpan input)
{
Result<char> next = input.ConsumeChar();
bool checkForHeader = true;
while (next.HasValue)
{
// need to check for a header when starting a new line
if (checkForHeader)
{
var headerStartLocation = next.Location;
var tokenQueue = new List<Result<Tokens>>();
while (next.HasValue && (next.Value == 'X' || next.Value == 'Y'))
{
tokenQueue.Add(Result.Value(next.Value == 'X' ? Tokens.X : Tokens.Y, next.Location, next.Remainder));
next = next.Remainder.ConsumeChar();
}
// only if we had at least one X or one Y
if (tokenQueue.Any())
{
if (next.HasValue && next.Value == ':')
{
// this is a header token; we have to return a Result of the start location
// along with the remainder at this location
yield return Result.Value(Tokens.Header, headerStartLocation, next.Remainder);
next = next.Remainder.ConsumeChar();
}
else
{
// this isn't a header; we have to return all the tokens we parsed up to this point
foreach (Result<Tokens> tokenResult in tokenQueue)
{
yield return tokenResult;
}
}
}
if (!next.HasValue)
yield break;
}
checkForHeader = false;
if (next.Value == '\r')
{
// skip over the carriage return
next = next.Remainder.ConsumeChar();
continue;
}
if (next.Value == '\n')
{
// line break; check for a header token here
next = next.Remainder.ConsumeChar();
checkForHeader = true;
continue;
}
if (next.Value == 'A')
{
var abcStart = next.Location;
next = next.Remainder.ConsumeChar();
if (next.HasValue && next.Value == 'B')
{
next = next.Remainder.ConsumeChar();
if (next.HasValue && next.Value == 'C')
{
yield return Result.Value(Tokens.ABC, abcStart, next.Remainder);
next = next.Remainder.ConsumeChar();
}
else
{
yield return Result.Empty<Tokens>(next.Location, $"unrecognized `AB{next.Value}`");
}
}
else
{
yield return Result.Empty<Tokens>(next.Location, $"unrecognized `A{next.Value}`");
}
}
else if (next.Value == 'X')
{
yield return Result.Value(Tokens.X, next.Location, next.Remainder);
next = next.Remainder.ConsumeChar();
}
else if (next.Value == 'Y')
{
yield return Result.Value(Tokens.Y, next.Location, next.Remainder);
next = next.Remainder.ConsumeChar();
}
else if (next.Value == ':')
{
yield return Result.Value(Tokens.Colon, next.Location, next.Remainder);
next = next.Remainder.ConsumeChar();
}
else if (next.Value == ' ')
{
yield return Result.Value(Tokens.Space, next.Location, next.Remainder);
next = next.Remainder.ConsumeChar();
}
else
{
yield return Result.Empty<Tokens>(next.Location, $"unrecognized `{next.Value}`");
next = next.Remainder.ConsumeChar(); // Skip the character anyway
}
}
}
}
And you can call it like this:
var tokens = new MyTokenizer().Tokenize(input);
i have a class that starts with a variable of type TreeNode in System.Windows.Forms. The class's functions job is to add some nodes to this variable .. but the problem is when i try to add some nodes to it the debugger freeze up and doesn't show any response .. I searched over the internet but i didn't find such a problem .This is one of those functions
NOTE : the line that produce issue is commented
public Node Factor()
{
Node result = new Node();
if (count < tokens.Count && tokens[count] == TokenType.LeftParentheses)
{
this.Match(TokenType.LeftParentheses);
result = this.Expression();
if (!this.Match(TokenType.RightParentheses))
return null;
result.viewnode.Text = "Expression";
}
else if (tokens[count] == TokenType.Num)
{
if (!this.Match(TokenType.Num))
return null;
NumberNode nnode = new NumberNode(lexemes[count - 1]);
nnode.childs = "NumberNode : Value " + nnode.value + '\n';
nnode.viewnode = new TreeNode("Number - Value = " + nnode.value);
result = nnode;
result.viewnode = nnode.viewnode;
result.viewnode.Nodes.Add(nnode.viewnode);
}
else
{
if (!this.Match(TokenType.ID))
return null;
IdNode inode = new IdNode(lexemes[count - 1], "0");
inode.childs = "IdNode - Value : " + inode.name + '\n';
inode.viewnode = new TreeNode("Id - " + inode.name);
result = inode;
result.viewnode = inode.viewnode;
//the program freezes at this line
inode.viewnode.Nodes.Add(inode.viewnode);
}
return result;
}
You are adding the node to itself.
should be result.viewnode ...
I have a question about read a text file, because i dont know if i'm thinking right. I want to read from specific string to specific character.
My text would look like this:
...
...
CM_ "Hello, how are you?
Rules: Don't smoke!
- love others
End";
...
CM_ "Why you?";
...// Many CM_
...
After Splited should look like that:
1. CM_
2. "Hello, how are you?
Rules: Don't smoke!
- love others
End"
3. CM_
4. "Why you?"
... // many CM_
I want to read from "CM_" till ";"
My Code i tried so far:
StreamReader fin = new StreamReader("text.txt");
string tmp = "";
tmp = fin.ReadToEnd();
if (tmp.StartsWith("CM_ ") && tmp.EndWith(";"))
{
var result = tmp.Split(new[] { '"' }).SelectMany((s, i) =>
{
if (i % 2 == 1) return new[] { s };
return s.Split(new[] { ' ', ';' }, StringSplitOptions.RemoveEmptyEntries);
}).ToList();
}
foreach (string x in result)
{
Console.WriteLine(x);
}
static void PRegex()
{
using (StreamReader fin = new StreamReader("text.txt"))
{
string tmp = fin.ReadToEnd();
var matches = Regex.Matches(tmp, "(CM_) ([^;]*);", RegexOptions.Singleline);
for (int i = 0; i < matches.Count; i++)
if (matches[i].Groups.Count == 3)
Console.WriteLine((2 * i + 1).ToString() + ". " + matches[i].Groups[1].Value + "\r\n" + (2 * (i + 1)).ToString() + ". " + matches[i].Groups[2].Value);
}
Console.ReadLine();
}
static void PLineByLine()
{
using (StreamReader fin = new StreamReader("text.txt"))
{
int index = 0;
string line = null;
string currentCMBlock = null;
bool endOfBlock = true;
while ((line = fin.ReadLine()) != null)
{
bool endOfLine = false;
while (!endOfLine)
{
if (endOfBlock)
{
int startIndex = line.IndexOf("CM_ ");
if (startIndex == -1)
{
endOfLine = true;
continue;
}
line = line.Substring(startIndex + 4, line.Length - startIndex - 4);
endOfBlock = false;
}
if (!endOfBlock)
{
int startIndex = line.IndexOf(";");
if (startIndex == -1)
{
currentCMBlock += line + "\r\n";
endOfLine = true;
continue;
}
currentCMBlock += line.Substring(0, startIndex);
if (!string.IsNullOrEmpty(currentCMBlock))
Console.WriteLine((++index) + ". CM_\r\n" + (++index) + ". " + currentCMBlock);
currentCMBlock = null;
line = line.Substring(startIndex + 1, line.Length - startIndex - 1);
endOfBlock = true;
}
}
}
}
Console.ReadLine();
}
You are reading the whole file into tmp. So, if there is any text before "CM_" then your conditional statement won't be entered.
Instead, try reading line by line with fin.ReadLine in a loop over all lines.
Read the whole file:
string FileToRead = File.ReadAllText("Path");
string GetContent(string StartAt, string EndAt, bool LastIndex)
{
string ReturnVal;
if(LastIndex)
{
ReturnVal = FileToRead.Remove(FileToRead.IndexOf(StartAt), FileToRead.IndexOf(EndAt));
Return ReturnVal;
}
else
{
ReturnVal = FileToRead.Remove(FileToRead.LastIndex(StartAt), FileToRead.LastIndex(EndAt));
Return ReturnVal;
}
}
-Hope I didn't do anything wrong here. (Free mind typing)
You read the file, and we remove all the content, infront of the first index. and all after it.
You can set it if will return the FIRST result found. or the last.
NOTE: I think it would be better to use a StringReader. (If I don't remember wrong...)
If you are to think about the memory usage of your application.
I tried something else, don't know if this is good. It still read the first Line, dont know that i did wrong here
my Code:
while ((tmp = fin.ReadLine()) != null)
{
if (tmp.StartsWith("CM_ "))
{
//string[] tmpList = tmp.Split(new Char[] { ' ', ';' }, StringSplitOptions.RemoveEmptyEntries);
var result = tmp.Split(new[] { '"' }).SelectMany((s, i) =>
{
if (i % 2 == 1) return new[] { s };
return s.Split(new[] { ' ', ';' }, StringSplitOptions.RemoveEmptyEntries);
}).ToList();
if (tmp.EndsWith(";")) break;
fin.ReadLine();
if (tmp.EndsWith(";"))
{
result.ToList();
break;
}
else
{
result.ToList();
fin.ReadLine();
}
foreach (string x in result)
{
Console.WriteLine(x);
}
}
I suggest you look into using Regular Expressions. It may be just what you need and much more flexible than Split().
I have some JSON data that looks like this:
{
"910719": {
"id": 910719,
"type": "asdf",
"ref_id": 7568
},
"910721": {
"id": 910721,
"type": "asdf",
"ref_id": 7568
},
"910723": {
"id": 910723,
"type": "asdf",
"ref_id": 7568
}
}
How can I parse this using JSON.net? I can first do this:
JObject jFoo = JObject.Parse(data);
I need to be able to iterate over each object in this list. I would like to be able to do something like this:
foreach (string ref_id in (string)jFoo["ref_id"]) {...}
or
foreach (JToken t in jFoo.Descendants())
{
Console.WriteLine((string)t["ref_id"]);
}
but of course that doesn't work. All the examples work great if you know the key while writing your code. It breaks down when you don't know the key in advance.
It's doable; this works but it's not elegant. I'm sure there's a better way.
var o = JObject.Parse(yourJsonString);
foreach (JToken child in o.Children())
{
foreach (JToken grandChild in child)
{
foreach (JToken grandGrandChild in grandChild)
{
var property = grandGrandChild as JProperty;
if (property != null)
{
Console.WriteLine(property.Name + ":" + property.Value);
}
}
}
}
Prints:
id:910719
type:asdf
ref_id:7568
id:910721
type:asdf
ref_id:7568
id:910723
type:asdf
ref_id:7568
You can iterate over the child objects with a simple LINQ query like this:
JObject jFoo = JObject.Parse(json);
foreach (JObject obj in jFoo.Properties().Select(p => p.Value))
{
Console.WriteLine("id: " + obj["id"]);
Console.WriteLine("type: " + obj["type"]);
Console.WriteLine("ref_id: " + obj["ref_id"]);
}
Fiddle: https://dotnetfiddle.net/fwINPa
Or if you just want all the ref_id values, you can do something like this:
string[] refIds = jFoo.Properties()
.Select(p => (string)p.Value["ref_id"])
.ToArray();
Console.Write(string.Join("\r\n", refIds));
Fiddle: https://dotnetfiddle.net/twOuVY
I'm using Json.NET and I wrote a quick way where you can print out all of the keys and corresponding values using a recursive method.
var o = JObject.Parse(YourJsonString);
getAllProperties(o); //call our recursive method
Then you can use this recursive method to get all the Properties and their values
void getAllProperties(JToken children)
{
foreach (JToken child in children.Children())
{
var property = child as JProperty;
if (property != null)
{
Console.WriteLine(property.Name + " " + property.Value);//print all of the values
}
getAllProperties(child);
}
}
Have you considered using JavascriptSerializer?
you could try do something like this:
JavaScriptSerializer serializer = new JavaScriptSerializer();
var foo = serializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(data);
foreach(var item in foo)
{
Console.Writeln(item.Value["ref_id"]);
}
http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx
Konstantin's solution will work but if you want a list of Id's do the same thing and instead of the Console.Writeln() use the following
List<string> list = new List<string>();
JavaScriptSerializer serializer = new JavaScriptSerializer();
var foo = serializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(data);
foreach(var item in foo)
{
list.Add(item.Value["ref_id"]);
}
I found TrueWill's answer worked, but I wanted to avoid foreach and try getting a simple for loop to work for the sake of speed. My results were certainly what could be described as ugly at best. Here they are in case they are useful for anyone. (I've left in WriteLine for the sake of being able to see things a bit easier.)
Note that this will not work for some JSON and isn't perfectly generic. Some null checks could be done better, etc.
// NOW, DOING IT ALL AS A FOR LOOP...
// a, b, c, d - for iterator counters.
// j1, j2, j3, j4 - the JTokens to iterator over - each is a child of the previous
// p, q, r, s - The properties from j1/2/3/4.
JObject o = JObject.Parse(json);
JToken j1 = o.First;
for (int a = 0; a < o.Children().Count(); a++) { // Outermost loop gives us result, error, id.
if (j1 == null)
continue;
if (a > 0) {
j1 = j1.Next;
if (j1 == null)
continue;
}
var p = j1 as JProperty;
Console.WriteLine("FOR 0 = " + a.ToString() + " --- " + p.Name);
// DO STUFF HERE.
// FIRST INNER LOOP
// Set up a JToken or continue
JToken j2 = j1.Children().First() as JToken;
if (j1.Children().Count() > 0) {
j2 = j1.Children().First() as JToken;
} else {
continue;
}
Console.WriteLine("*** STARTING FIRST INNER...");
for (int b = 0; b < j1.Children().Count(); b++) { // returns nothing as second loop above.
if (j2 == null) {
Console.WriteLine("*** j2 null 1...");
continue;
}
if (b > 0) {
j2 = j2.Next;
if (j2 == null) {
Console.WriteLine("*** j2 null 2...");
continue;
}
}
var q = j2 as JProperty;
// These null checks need to be != or ==, depending on what's needed.
if (q != null) {
Console.WriteLine("FOR 1 = " + a.ToString() + ","
+ b.ToString() + " --- " + q.Name);
// DO STUFF HERE.
// ...
} // q !null check
// SECOND INNER LOOP
// Set up a JToken or continue
JToken j3;
if (j2.Children().Count() > 0) {
j3 = j2.Children().First() as JToken;
} else {
continue;
}
Console.WriteLine("****** STARTING SECOND INNER...");
for (int c = 0; c < j2.Children().Count(); c++) {
if (j3 == null)
continue;
if (c > 0) {
j3 = j3.Next;
if (j3 == null)
continue;
}
var r = j3 as JProperty;
if (r == null) {
continue;
} // r null check
Console.WriteLine("FOR 2 = "
+ a.ToString() + ","
+ b.ToString() + ","
+ c.ToString() + " --- " + r.Name);
// DO STUFF HERE.
// THIRD INNER LOOP
// Set up a JToken or continue
JToken j4;
if (j3.Children().Count() > 0) {
j4 = j3.Children().First() as JToken;
} else {
continue;
}
Console.WriteLine("********* STARTING THIRD INNER...");
for (int d = 0; d < j3.Children().Count(); d++) {
if (j4 == null)
continue;
if (c > 0) {
j4 = j4.Next;
if (j4 == null)
continue;
}
var s = j4 as JProperty;
if (s == null) {
continue;
} // s null check
Console.WriteLine("FOR 3 = "
+ a.ToString() + ","
+ b.ToString() + ","
+ c.ToString() + ","
+ d.ToString() + " --- " + s.Name);
// DO STUFF HERE.
// ...
} // for d - j3
} // for c - j2
} // for b - j1
} // for a - original JObject