For the complete documentation index, see llms.txt. This page is also available as Markdown.

Zongsoft.Serialization

Understanding serialization boundaries from Discussions user archive filtering and model properties.

Serializer.Json supports Zongsoft model and data dictionary and other framework types based on System.Text.Json. It is used by the Discussions user archive provider to reduce the input stream to a conditional model and then hands it to the data service.

The Real Input Is Not an Arbitrary Object Graph

Source: src/Features/Archiving/UserDataTemplateModelProvider.cs (excerpt; see source for context).

UserDataTemplateModelProvider.cs
public override IDataTemplateModel GetModel(IDataTemplate template, object argument)
{
	var schema = $"*, {nameof(UserProfile.Site)}" + "{*}";

	if(argument is Stream stream)
		argument = Serializer.Json.Deserialize<UserProfileCriteria>(stream);

	var data = argument switch
	{
		string key => this.Services.ResolveRequired<UserService>().Get(key, schema),
		IModel model => this.Services.ResolveRequired<UserService>().Select(Criteria.Transform(model), schema),
		_ => this.Services.ResolveRequired<UserService>().Select(null, schema),
	};

	return new DataTemplateModel(new { Users = data });
}

The stream input explicitly specifies UserProfileCriteria, which is then converted into data conditions via Criteria.Transform. String input is queried according to the user key; these two paths are different, and the input should not be deserialized into a Dictionary and then spliced into SQL.

Model Fields and Output Ranges

Source: src/Models/Post.cs (excerpt; see source for context).

The ignored member attribute controls serialization visibility and does not mean that these members do not exist in the database, nor does it replace schema or authorization. Before the model returns the text, it will also go through audit filtering and external content reading.

Framework Options Reference

Options
Purpose

Indented

Readable indented output

NamingConvention

Member naming convention

IgnoreNull、IgnoreZero

Control empty or default value output

IncludeFields

Whether to include fields

MaximumDepth

object graph depth limit

Typified

Preserve type information for loose values

Discussions does not currently use Typified or a custom JSON converter as an archive entry point. Related real tests can be found at JsonSerializerTest and TextSerializationOptionsTest.

Security and Lifecycle

Successful deserialization only indicates that the input can be parsed, but does not indicate that the caller has the right to query or export the corresponding user. Limit input size and object depth, propagate cancellation signals, and let the service layer continue to validate business scope. The workbook structure of the archive output is shown in spreadsheets and templates.

Last updated