1. Handle the String to JSON in Backend? Frontend?
- Frontend is better in my case, frontend need the raw data, by the way, in backend, we may need to import json-lib dependencies using
group: 'com.hynnet', name:'json-lib', version:'2.4'
or maybecompile 'net.sf.json-lib:json-lib:2.4:jdk8'
in gradle to import dependencies, or build our own component with @Data annotation, etc. Frontend is easier to handle.
2. How to handle raw JSON string with \r\n in frontend in JSX?
-
If we use JSON.parse directly on that each string in the String Array, it will have error “
Object with keys cannot be a React child
”, since after JSON.parse, each string will become Json format with keys and values. -
If we use JSON.stringify on that