On Mon, Feb 4, 2019 at 6:05 PM Fhakruddin Mohamed
<[email protected]> wrote:
>
> Writerbasedgenerator.class
> In case of of xml something like this <test result/> gets converted to {
> test result: [null]
> }
> This is not correct JSOn format.
> Please help

Jackson does not convert from XML to JSON or vice versa.
You are doing something, and it'd be necessary to see code you are using.
WriterBasedGenerator only encodes a sequence of tokens, API being
based on logical content model of json. With XML it has to map this
sequence in some way to XML equivalents of Elements, Attributes and
Character Data (text).

But do note that JSON and XML are very different formats,
structurally, so conversion between the two is often asymmetric and
can not be lossless in general case.
Because of this the only safe way to convert is to read one into
POJOs, and then write the other: attempting to use -- for example --
JsonNode in between is not recommended and will not work for all
cases. Lists/arrays are notoriously difficult to handle because XML
has no native mechanism to distinguish "Objects" (struct / hash /
mapping) from "Arrays" (list / collection / sequence), in sense JSON
and most programming languages do.

-+ Tatu +-



> On Tue, Feb 5, 2019, 03:53 Tatu Saloranta <[email protected] wrote:
>>
>> On Fri, Feb 1, 2019 at 4:57 PM Fhakruddin Mohamed
>> <[email protected]> wrote:
>> >
>> > {
>> >  test: []
>> > }
>> >
>> > This result is not achievable.
>> >
>> > Please advice.
>>
>> Unfortunately I do not quite understand what your problem is here.
>> What are you trying to do? With what kind of code?
>>
>> -+ 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 post to this group, send email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> 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 post to this group, send email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
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 post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to