feat(audience): Json.Serialize pretty-print overload + Samples.SampleApp IVT (SDK-231)#705
Merged
ImmutableJeffrey merged 2 commits intomainfrom Apr 24, 2026
Merged
Conversation
ece952d to
85c7b38
Compare
3 tasks
Second overload indenting nested containers by `indent` spaces per
level. Round-trips through Deserialize identically; indent ≤ 0
routes to the existing compact Serialize, so every wire-payload
caller is unaffected.
Internal scaffolding:
- WriteObject / WriteArray / WriteValue thread indent + depth so the
overload can emit newlines and leading spaces at the correct
nesting level.
- AppendNewline helper centralises the "\n + (indent * depth) spaces"
pattern.
- pretty-path writes ":" with a trailing space; empty containers stay
on a single line ({} / []), matching the compact form for collapsed
nodes.
No behaviour change on the compact overload for any existing caller;
the indent threading is inert when indent == 0 (pretty=false).
Motivated by the sample-app landing next — its Init tab renders the
effective AudienceConfig as an echo view, and the Events/Identity
tabs show constructed property dicts, all via Json.Serialize(…, 2).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…tor from headless build IVT lets the in-repo SampleApp reach Json.Serialize and JsonReader.DeserializeObject — helpers the public API does not expose. csproj Remove="Editor/**/*.cs" is a no-op today; prereq for the sample-app PR, whose editor tests reference Unity-only types that fail the headless dotnet build. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
85c7b38 to
73d3e46
Compare
nattb8
approved these changes
Apr 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Json.Serialize(dict, indent)pretty-print overload —indent ≤ 0routes to the compactSerialize, so every wire-payload caller is unaffected.InternalsVisibleTo("Immutable.Audience.Samples.SampleApp")so the in-repo sample reachesJson.Serialize/JsonReader.DeserializeObjectwithout widening the public API.Audience.Tests.csprojexcludesEditor/**/*.csfrom the headless dotnet build — no-op today, prereq for the sample-app PR whose editor-only tests reference Unity types.Closes SDK-231. Prereq for SDK-230 (Unity Audience SampleApp) landing next.
Test plan
dotnet test src/Packages/Audience/Tests/Audience.Tests.csprojpasses.JsonTestsfixture still passes; pretty-print round-trips throughDeserializeidentically.🤖 Generated with Claude Code
Note
Medium Risk
Touches core JSON serialization used for event storage/network payloads; while the default compact path is intended to be unchanged, regressions could affect message formatting/round-tripping. Build changes also alter which tests compile in headless CI, potentially hiding Unity-only failures outside the Unity runner.
Overview
Adds a new
Json.Serialize(dict, indent)overload to optionally pretty-print JSON with indentation, while keeping the existingSerialize(dict)as the compact default for wire/disk payloads.Refactors the JSON writer to thread
indent/depththrough object/array/value writing and insert newlines/spaces only when pretty-printing. Also grantsInternalsVisibleToforImmutable.Audience.Samples.SampleAppand excludesEditor/**/*.csfrom the headlessAudience.Testsbuild to avoid Unity-only compile dependencies.Reviewed by Cursor Bugbot for commit 73d3e46. Bugbot is set up for automated code reviews on this repo. Configure here.