• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

How to pass an ArrayList<Pojo> and a Pojo inside a JSON using JACKSON ObjectMapper method

Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi i'm trying to pass an ArrayList<Pojo> and Pojo inside a JSON using JACKSON ObjectMapper method, i'm trying to do this by concatenating the resulting string of mapping the ArrayList<Pojo> and the resulting string of mapping the Pojo alone, i concat these two, by thinking they are going to be a valid json containing my ArrayList of Pojos and my different type of Pojo alone, but i don't know how to concat these to string to from a valid JSON, if there a way to do this?

This is the method where i'm trying to create my Json

the json returning is not valid since my chrome browser give's me that it found a unexpected token "{" in the json string

here is the resulting json string

is obvious that when it reach to this line

it says that is not the format, but how can i concat this two strings? since the kind of use a jackson json notation (i'm not sure since i'm new in JSON).

1) Does JACKSON have a method where you can pass it an Arraylist of objects and as a second parameter my Object of a different type of objects that have the ArrayList, so jackson can map it

2) If JACKSON don't have this method can i concat the two strings to form a valid JSON, and by this i mean concat the two string that return ObjectMapper method and don't creating a JSON string by myself

3) If i can concat the to strings i mention to create a JSON string and i would have to create one by myself how would it be?

i acctually don't want to do the third option, but if option 1 or 2 are not valid i think i don't have another choice, also i thinking of creating a class with the atributes of the Alone Pojo an Arraylist but i think that creating a class just for this is not really necesary.

thanks in advance.
I can't renounce my name. It's on all my stationery! And hinted in this tiny ad:
a bit of art, as a gift, the permaculture playing cards
    Bookmark Topic Watch Topic
  • New Topic