JSON prefix in MappingJackson2HttpMessageConverter

I am using Spring / AngularJS and to prevent JSON vulnerability, I am trying to prefix all JSON array responses with ")]} ', \ n" - see link .

I was able to prefix

     <mvc:annotation-driven>
     <mvc:message-converters>
     <bean id="mappingJackson2HttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" >
     <property name="jsonPrefix" value=")]}',\n" />
     </bean>
     </mvc:message-converters>
     </mvc:annotation-driven>

      

But the problem is that it prefix all JSON responses with ")]} ', \ n" and I only need to prefix the JSON arrays. Is there a way to set a prefix for JSON array responses? Thank.

0


source to share


1 answer


Rather than having a prefix that basically invalidates your response, JSON is considering returning an object instead of an array. This will also reduce the attack vector.



{d: [1,2,3,4]}

      

-1


source







All Articles