Pass json object from database through service

Hi Guys,

I have a native sql query that returns an object like follows:

"99138386-1" "[{"2018-05-01": 0.000}, {"2018-05-02": 32.23"}]"

Can I pass that directly as an object through the rest services somehow?

The following seems to work. Not sure if it’s the right way to go about it…

public List<Object[]> myObjects(String item, Date startDate, Date endDate) {        
    EntityManager em = persistence.getEntityManager();
    @SuppressWarnings("unchecked")
    List<Object[]> results = em
            .createNativeQuery(
                    "....")
            .setParameter(1, item)
            .setParameter(2, startDate)
            .setParameter(3, endDate)
            .getResultList();

    return results;
}