in src/SourcemapToolkit.SourcemapParser/SourceMapGenerator.cs [91:129]
public string SerializeMapping(SourceMap sourceMap, JsonSerializerSettings jsonSerializerSettings = null)
{
if (sourceMap == null)
{
throw new ArgumentNullException(nameof(sourceMap));
}
string mappings = null;
if (sourceMap.ParsedMappings != null && sourceMap.ParsedMappings.Count > 0)
{
MappingGenerateState state = new MappingGenerateState(sourceMap.Names, sourceMap.Sources);
StringBuilder output = new StringBuilder();
foreach (MappingEntry entry in sourceMap.ParsedMappings)
{
SerializeMappingEntry(entry, state, output);
}
output.Append(';');
mappings = output.ToString();
}
SourceMap mapToSerialize = new SourceMap(
version: sourceMap.Version,
file: sourceMap.File,
mappings: mappings,
sources: sourceMap.Sources,
names: sourceMap.Names,
parsedMappings: default,
sourcesContent: sourceMap.SourcesContent);
return JsonConvert.SerializeObject(mapToSerialize,
jsonSerializerSettings ?? new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore,
});
}