0% found this document useful (0 votes)
320 views

Hands-On JSON Verify JSON Datatypes

This document discusses validating JSON schemas by changing data types and returning required JSON data. It loads student data from a test JSON file, parses it, iterates through each student object to convert the aggregate score to an integer, and further iterates through each subject score to convert those to integers as well. It then returns the modified student data JSON.

Uploaded by

maribel torres
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
320 views

Hands-On JSON Verify JSON Datatypes

This document discusses validating JSON schemas by changing data types and returning required JSON data. It loads student data from a test JSON file, parses it, iterates through each student object to convert the aggregate score to an integer, and further iterates through each subject score to convert those to integers as well. It then returns the modified student data JSON.

Uploaded by

maribel torres
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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