Is there a technique or module I can use in my node project that will take in JSON from a rest API and store it in some sort of readable object?
I understand currently that when I get data from a REST API, express's body parser will store it as a JSON object for me and I can traverse the tree from there, my issue is what if a contributor to my project has no idea what the JSON from the REST API looks like.
In Java you can tell since JACKSON will map it to a Java bean, in JavaScript I feel like you are going in blindly. If a contributor is using sublime and they don't have a debugger how should they figure out what the JSON object looks like?
In nodejs, you can use express-jsonschema
package to validate the incoming json to rest endpoints. If the json is not compliant with schema, you can respond with bad request error ( http status 400).
Please look more about this package on package manager (npmjs.com).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With