process method

String process(
  1. String jsonString,
  2. Map<String, dynamic> data, {
  3. Map<String, String>? templates,
})

Implementation

String process(String jsonString, Map<String, dynamic> data,
    {Map<String, String>? templates}) {
  // Remove comments before processing
  final jsonWithoutComments = _removeComments(jsonString);

  // Convert JSON string to Dart object (Map or List)
  final decodedJson = json.decode(jsonWithoutComments);

  // Recursively replace placeholders
  final processedJson = _replacePlaceholdersRecursive(
    decodedJson,
    data,
    templates,
  );

  // Convert Dart object back to JSON string
  return json.encode(processedJson);
}