content: import 'dart:convert';
  import 'package:dart_json_mapper/dart_json_mapper.dart';
  import 'package:test/test.dart';
  
  // Models as defined in the GitHub issue
  @jsonSerializable
  class MyObject {
    @JsonProperty(name: 'name')
    final String name;
  
    @JsonProperty(flatten: true)
    final FlattenObject page;
  
    MyObject({
      required this.name,
      required this.page,
    });
  }
  
  @jsonSerializable
  class FlattenObject {
    @JsonProperty(name: 'pageNumber')
    final int pageNumber;
  
    @JsonProperty(name: 'pageSize')
    final int pageSize;
  
    FlattenObject({
      required this.pageNumber,
      required this.pageSize,
    });
  }
  
  // Note: For these tests to run correctly with dart_json_mapper,
  // the necessary .mapper.g.dart files must be generated by build_runner.
  // This typically involves:
  // 1. Ensuring these classes are discoverable by build_runner (e.g., via a part file
  //    or being included in a library that build_runner processes).
  // 2. Running `dart run build_runner build --delete-conflicting-outputs`
  // 3. Importing the generated main adapter initialization file and calling its init method
  //    (e.g., `import 'path/to/generated_adapter.init.dart'; initializeJsonMapper();`)
  //    usually in a setupTest.dart or at the beginning of the main test file.
  
  void testFlatten() {
    group('JsonProperty(flatten: true) tests', () {
      test('can deserialize with flatten: true', () {
        const jsonString = """
          {
            "name": "Lost Mine of Phandelver",
            "pageNumber": 1,
            "pageSize": 10
          }
        """;
  
        final decodedJson = jsonDecode(jsonString);
        final actual = JsonMapper.deserialize<MyObject>(decodedJson);
  
        expect(actual, isA<MyObject>());
        expect(actual?.name, 'Lost Mine of Phandelver');
        expect(actual?.page, isA<FlattenObject>());
        expect(actual?.page.pageNumber, 1);
        expect(actual?.page.pageSize, 10);
      });
  
      test('can serialize with flatten: true', () {
        const expectedJsonString = """
  {
   "name": "Lost Mine of Phandelver",
   "pageNumber": 1,
   "pageSize": 10
  }""";
  
        final myObject = MyObject(
          name: 'Lost Mine of Phandelver',
          page: FlattenObject(pageNumber: 1, pageSize: 10),
        );
  
        final actualJson = JsonMapper.serialize(myObject);
        final expectedMap = jsonDecode(expectedJsonString);
        final actualMap = jsonDecode(actualJson);
        
        expect(actualMap, equals(expectedMap));
      });
    });
  }
  