Skip to content

Commit c88afbd

Browse files
committed
Update js-utils.md
1 parent 00ca84f commit c88afbd

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

MyApp/_pages/js-utils.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,18 @@ It can be used to parse dynamic JSON and any primitive JavaScript data type. The
3131

3232
C# Pattern matching provides a powerful and intuitive approach for introspecting JSON objects by leveraging C#'s native type checking and destructuring capabilities which is ideal when working with dynamic JSON data parsed into generic collections like `Dictionary<string, object>` and `List<object>` where it naturally integrates with C#'s control flow, making it easier to handle complex nested JSON structures while maintaining clean, expressive code that clearly communicates the expected data structure and extraction logic.
3333

34-
### Getting the client_id in a ComfyUI Output
34+
### Getting the client_id out of a ComfyUI Output
3535

3636
```csharp
3737
var comfyOutput = JSON.ParseObject(json);
3838
var prompt = (Dictionary<string, object?>)result.Values.First()!;
3939
if (prompt.TryGetValue("prompt", out List<object> promptTuple) && promptTuple.Count > 3)
4040
{
4141
var extraData = promptTuple[3];
42-
if (extraData is Dictionary<string, object?> extraDataDict)
42+
if (extraData is Dictionary<string, object?> extraDataDict
43+
&& extraDataDict.TryGetValue("client_id", out string clientId))
4344
{
44-
if (extraDataDict.TryGetValue("client_id", out string clientId))
45-
{
46-
ret.ClientId = clientId;
47-
}
45+
Console.WriteLine(clientId);
4846
}
4947
}
5048
```

0 commit comments

Comments
 (0)