Skip to main content
Each Result can hold a metadata dictionary alongside its answers. Use it for collection details, study tags, or navigation history associated with that interview.
This API is introduced in PR #2577. The examples require an EDSL version containing the change. Per-result metadata is separate from a remote object’s description, visibility, and other sharing metadata.

Create a result with metadata

This example constructs a result locally without making model calls:
Metadata defaults to an empty dictionary. Its values may contain strings, booleans, integers, finite floats, None, lists, and nested dictionaries with string keys. Convert dates to strings and other custom objects to JSON-compatible values before attaching them. Sets, tuples, non-string dictionary keys, and non-finite floats are rejected with TypeError during construction.

Select metadata alongside answers

Top-level metadata keys become columns under metadata.*:
Selecting a nested object returns that object as a column value. For example, select metadata.collection, then read value["wave"]; this API does not flatten every nested key into its own column.

Save and restore

Metadata survives dictionary serialization and .ep package round trips:
Older serialized results without a metadata field load with an empty dictionary. Metadata is preserved when selecting or renaming questions, and remote result reconstruction carries through metadata supplied in the response. Metadata remains opaque JSON: dictionaries that resemble serialized EDSL objects are not converted into those objects.

Preserve a local session’s navigation history

SurveySession exposes active answers and audit metadata separately. Starting from the survey above, explicitly combine them in a Result:
humanize_navigation contains events and inactive_answers. Events record answer revisions and navigation actions; inactive answers retain values removed when a revised answer invalidates the later path. Only active answers appear in session_result.answer. History includes the recorded answer values, so it can retain answers that are no longer active. This attachment is explicit in the local API. The PR does not by itself establish that hosted Humanize responses automatically populate navigation metadata. See Back navigation for boundaries, branching, and session behavior.