mirror of
https://github.com/AssetRipper/AssetRipper.git
synced 2025-12-11 20:15:29 +01:00
Handle empty lists and dictionaries in JSON output
Updated `EnterList<T>` to write "[]" for empty lists and return false.
Modified `EnterDictionary<TKey, TValue>` to write "{}" for empty string-keyed dictionaries and "[]" for empty non-string-keyed dictionaries, also returning false.
These changes ensure a more succinct representation of empty collections in the output.
This commit is contained in:
parent
a95f69f42e
commit
a9685e3dc6
@ -74,6 +74,12 @@ public class DefaultJsonWalker : AssetWalker
|
||||
|
||||
public override bool EnterList<T>(IReadOnlyList<T> list)
|
||||
{
|
||||
if (list.Count == 0)
|
||||
{
|
||||
Writer.Write("[]");
|
||||
return false;
|
||||
}
|
||||
|
||||
Writer.WriteLine('[');
|
||||
Writer.Indent++;
|
||||
return true;
|
||||
@ -95,11 +101,23 @@ public class DefaultJsonWalker : AssetWalker
|
||||
{
|
||||
if (IsString<TKey>())
|
||||
{
|
||||
if (dictionary.Count == 0)
|
||||
{
|
||||
Writer.Write("{}");
|
||||
return false;
|
||||
}
|
||||
|
||||
Writer.WriteLine('{');
|
||||
Writer.Indent++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dictionary.Count == 0)
|
||||
{
|
||||
Writer.Write("[]");
|
||||
return false;
|
||||
}
|
||||
|
||||
Writer.WriteLine('[');
|
||||
Writer.Indent++;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user