Skip to content
This repository was archived by the owner on Apr 28, 2020. It is now read-only.

Implement one Json5.Parse overload #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Json5/Json5.cs
Original file line number Diff line number Diff line change
@@ -32,7 +32,16 @@ public static Json5Value Parse(string text, Func<Json5Container, string, Json5Va

public static Json5Value Parse(string text, Func<string, Json5Value, Json5Value> reviver)
{
throw new NotImplementedException();
Json5Parser parser = new Json5Parser(new StringReader(text));
Json5Value value = parser.Parse();

if (reviver != null)
{
Func<Json5Container, string, Json5Value, Json5Value> finalReviver = (t, k, v) => reviver(k, v);
return Transform(value, finalReviver);
}

return value;
}

public static string Stringify(Json5Value value, Func<Json5Container, string, Json5Value, Json5Value> replacer, string space = null)