// code is duplicated for optimizations reasons. /// <summary> /// Searches for one of the fields in the keys /// </summary> /// <param name="searchDescendants">True to look through the entire subtree, otherwise, false</param> /// <param name="anyOfKeys">The keys to look for</param> /// <returns></returns> public bool SkipToAnyOfFields(string[] anyOfKeys, bool searchDescendants) { string val; if (searchDescendants) { while (Read()) { if (1 == _state) // key { val = JsonObject.UndecorateString(_pc.GetCapture()); if (-1 < Array.IndexOf(anyOfKeys, val)) { return(true); } } } return(false); } switch (_state) { case -1: if (Read()) { return(SkipToAnyOfFields(anyOfKeys)); } return(false); case 4: while (Read() && 1 == _state) // first read will move to the child field of the root { val = JsonObject.UndecorateString(_pc.GetCapture()); if (0 > Array.IndexOf(anyOfKeys, val)) { SkipSubtree(); // if this field isn't the target so just skip over the rest of it } else { break; } } return(1 == _state); case 1: // we're already on a field val = JsonObject.UndecorateString(_pc.GetCapture()); if (-1 < Array.IndexOf(anyOfKeys, val)) { return(true); } else if (!SkipSubtree()) { return(false); } while (Read() && 1 == _state) // first read will move to the child field of the root { val = JsonObject.UndecorateString(_pc.GetCapture()); if (0 > Array.IndexOf(anyOfKeys, val)) { SkipSubtree(); // if this field isn't the target just skip over the rest of it } else { break; } } return(1 == _state); default: return(false); } }