Hands-On JSON Verify JSON Datatypes

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

1.

Welcome to JSON schema validation : Change


datatypes and return required JSON data
Verify JSON Datatypes

File Name: tindex.js

module.exports= function(){

const data = require("./testdata.json");

/*Explore the JSON file and return required JSON data*/

var json = JSON.parse(data).studentData;

json.forEach(function(element, index){

element['aggregate'] = parseInt(element['aggregate']);

element.forEach(function(per,ind){

per['sub1'] = parseInt(per['sub1']);
per['sub2'] = parseInt(per['sub2']);

per['sub3'] = parseInt(per['sub3']);

});

});

return json;

You might also like