jackson achieve conversion json

The first step guide package. Jar package import or import maven project coordinates ( Jackson-Annotations; Jackson-Core; Jackson-DataBind )

Next, create an object class ObjectMapper core by no-argument constructor

The third step, by calling the object ObjectMapper WriteValue (parameter, obj) or writeValueAsString (obj) method parameter is the object obj to be converted:

              Parameter 1 in WriteValue (parameters, obj):

                         File: json object into a string, saved in the specified file

                         Writer: json object into a string, and the character data to populate json output stream

                         outputStream: json object into a string, and json data output stream of bytes filled

   in writeValueAsString ( obj) in the target string into json

Guess you like

Origin www.cnblogs.com/kitor/p/10986628.html