Check if string either contains xml or json data

Viewed 14877

I receive a String which contains either xml or json contents.

If String contains json content I use jackson(java api) to Convert JSON to Java object

And if it contains xml contents I use JAXB to Convert XML content into a Java Object(Unmarshalling).

How can I check whether I receive xml or json in that string?

2 Answers
Related