tristanhimmelman / ObjectMapper

Simple JSON Object mapping written in Swift
MIT License
9.15k stars 1.04k forks source link

Custom indentation problem using YAMLFactory #911

Closed mike03081972 closed 6 years ago

mike03081972 commented 6 years ago

Hi,

If I use YAMLFactory instead of default JSON factory, my custom indentation is not taken into account.

Any idea ?

DefaultPrettyPrinter.Indenter indenter = new DefaultIndenter("    ", DefaultIndenter.SYS_LF);
DefaultPrettyPrinter printer = new DefaultPrettyPrinter();
printer.indentObjectsWith(indenter);
printer.indentArraysWith(indenter);

ObjectMapper objectMapper = new ObjectMapper( new YAMLFactory() );
objectMapper.setDefaultPrettyPrinter(printer);
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);

String yaml= objectMapper.writeValueAsString(myObject);
tristanhimmelman commented 6 years ago

I think you have posted this into the wrong repository. This is the Swift version of ObjectMapper for iOS and macOS. It does not support custom JSON factories at this time.