On Wed, May 13, 2020 at 2:51 PM Omar Alkhateeb <[email protected]> wrote:

> 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
>
> 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 :
>
>
>
> 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
>
>
I am sorry but that is a very complex sequence of things, for some reason
even including GSON for json parsing instead of Jackson.

If some characters get changed unexpectedly you will probably need to
figure out the specific part of processing that does it.
Use of CharacterEscapes should not be necessary: text values should retain
their exact contents.

-+ Tatu +-

-- 
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/CAL4a10iP%2BBUwsVaeZCB%2BUrTZBGJ8Gg-%3D-hfuu%2BaycEGUD%3DhyAw%40mail.gmail.com.

Reply via email to