Skip to content

Commit 2533ebb

Browse files
authored
Merge pull request #70 from schveiguy/docs-for-parseTo
chore(docs): Update docs for parseTo to reflect both object and array
2 parents 2000267 + 53d091e commit 2533ebb

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

source/iopipe/json/parser.d

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,20 +2049,29 @@ struct JSONTokenizer(Chain, ParseConfig cfg)
20492049

20502050
/**
20512051
* Parse until it finds a specific member/submember. The assumption is that
2052-
* the current item is an object start.
2053-
2054-
* Supported member types are strings, which represent object-keys and
2055-
* ulongs, which represent 0-indexed array indices.
2056-
2057-
* Returns true if the specified submember was found, and the parser is
2058-
* queued to parse the value of that member.
2059-
2060-
* Returns false if the object was searched, but the submember could not be
2061-
* found. In this case, the stream is left in a location that is
2062-
* potentially partly advanced. Use caching to rewind if you don't wish to
2063-
* lose the current position.
2064-
2065-
* Also returns false if this is not an object (without consuming anything).
2052+
* the current item is an object or array start (depending on the target
2053+
* key type).
2054+
*
2055+
* Params:
2056+
* key - String member to parse to. Current stream is assumed to be
2057+
* aligned to an object start.
2058+
* idx - Index of the element to parse to. Current stream is assumed to
2059+
* be aligned to an array start.
2060+
* submembers - List of nested members to parse to. Similar to single
2061+
* `key` or `idx`, but recurses through all the aggregates of the
2062+
* stream for each item in the arugments.
2063+
*
2064+
* Returns: true if the specified key or index was found, and the parser is
2065+
* aligned to parse the value of that member.
2066+
*
2067+
* Returns: false if the stream was searched, but the target could not be
2068+
* found. In this case, the stream is left in a location that is
2069+
* potentially partly advanced. Use caching to rewind if you don't wish
2070+
* to lose the current position.
2071+
*
2072+
* Note: if any of the containers were not as expected (e.g. a string key
2073+
* was passed, but the aggregate at that point was an array), the return
2074+
* value will be false.
20662075
*/
20672076
bool parseTo(string key)
20682077
{

0 commit comments

Comments
 (0)