Hi All,

I have issue while using ObjectMapper with YAMLFactory to Parse a YAML File

 

1.       The YAML file I’m trying to parse : 
https://drive.google.com/open?id=1Q85OmjH-IAIkordikLTsC1oQVTg8ggc8 
<https://ct-url-protection.portal.checkpoint.com/v1/load/9AuMo-jZi34grLb7iFscEasON-heMu2G5RT74LRoZ8dUV1N4IeTwVwnPYRhnH6YL8GuO-3bSgR6KbsIj6k2k0ZT8pJDhf4BM7N48qOsa-VSbpq1PdZjxQf011YVnaWnxB6hxtMmUf5kHQKYunRLj1J42cSlIz9gjMBd2kTK-Tdibg4OWLA8n5dp1efo76MhGo6N6WWjYcGtwFbZAd_LRyBJH8weptG3Fz4VLoXQfg84D5AeaIjvncyB1SIQmfY6DCDYScNhQWJxvAnmUwkDJ5mcIwZlX07nLjpKeg458FT0-gpuAM0KtNr7TJsbFbUvNBMaot-80Fla0AtwKMDz-kuIVKJNo7os2hFlA0KJZAT5pRf5rwEdbOrF33diWAzsHUnzujTeuSxE?original_url=https%3A%2F%2Fdrive.google.com%2Fopen%3Fid%3D1Q85OmjH-IAIkordikLTsC1oQVTg8ggc8>

2.       Parsing the File using readValue as shown here :

 

ObjectMapper mapper = *new* ObjectMapper(*new* YAMLFactory().enable(Feature.
*MINIMIZE_QUOTES*)//

                .disable(Feature.*WRITE_DOC_START_MARKER*)//

                .disable(YAMLGenerator.Feature.*SPLIT_LINES*));

// mapper.getFactory().setCharacterEscapes(new YAMLCharacterEscapes());

TypeReference<HashMap<String, Object>> typeRef = *new* 
TypeReference<HashMap<String, Object>>() {};

HashMap<String, Object> obj = mapper.readValue(responseBuffer.toString(), 
typeRef);

 

3.       Converting the Obj to json then to YAML again by : 

 

JsonElement jsonElem = *wrapJacksonObject*(obj);

        String cloudTemplateJsonString = *new* 
GsonBuilder().disableHtmlEscaping().setPrettyPrinting()//

                .create()//

                .toJson(jsonElem);

 

        JsonNode jsonNode = mapper.readTree(cloudTemplateJsonString);

        String yaml = *new* YAMLMapper().enable(Feature.*MINIMIZE_QUOTES*)//

                .disable(Feature.*WRITE_DOC_START_MARKER*)//

                .writeValueAsString(jsonNode);

 

4.       After checking the last String, I see that these Special 
Characters are Changed/Deleted (they are Changed exactly after Point 2) :

 

a.       ‘ transferred to “ or Deleted

b.       ! : Regarding the exclamation mark : the whole string after it 
until first space is deleted totally :

 

Diff Examples on what I talking about : 


[image: YamlDiff1.jpg]

[image: YAMLDiff2.jpg]


 

5.       I try to use Escape Characters Customization By customizing 
Implementation for *CharacterEscapes* class but it didn’t help

 

Do you have any suggestions ? Please help me I really need your help to 
success my project

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jackson-user/0d565161-62c8-4901-b1e4-5ed2ee662aee%40googlegroups.com.

Reply via email to