Created
April 30, 2020 05:23
-
-
Save drepram/54592e976f51aa6d9cfd3f65ac8bce10 to your computer and use it in GitHub Desktop.
The problem with JavaScript Object Field escape characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let objek = { | |
"subjek": "10mat", | |
"10mat1": { | |
"id": "10mat1", | |
"noPertanyaan": 1, | |
"pertanyaan": "", | |
"jawaban": { | |
"a": "$ b - a < x - y < a - b $", | |
"b": "$ a - b < x - y < b - a $", | |
"c": "$ \frac {1}{2}\\ (b-a) < x - y < \frac {1}{2}\\ (a-b) $", | |
"d": "$ \frac {1}{2}\\ (a-b) < x - y < \frac {1}{2}\\ (b-a) $" | |
}, | |
"kunci": "c" | |
}, | |
"10mat2": { | |
"id": "10mat2", | |
"noPertanyaan": 2, | |
"pertanyaan": "", | |
"jawaban": { | |
"a": "$ 2 \\leq x \\leq 3 $", | |
"b": "$ -1 \leq x \leq 2 $", | |
"c": "$ x \leq{2}\ \text{atau}\ x \geq{3}\ $", | |
"d": "$ x \leq{-1}\ \text{atau}\ x \geq{2}\ $" | |
}, | |
"kunci": "e" | |
}, | |
"10mat3": { | |
"id": "10mat3", | |
"noPertanyaan": 3, | |
"pertanyaan": "", | |
"jawaban": { | |
"a": "", | |
"b": "", | |
"c": "", | |
"d": "" | |
}, | |
"kunci": "c" | |
}, | |
"10mat4": { | |
"id": "10mat4", | |
"noPertanyaan": 4, | |
"pertanyaan": "", | |
"jawaban": { | |
"a": "", | |
"b": "", | |
"c": "", | |
"d": "" | |
}, | |
"kunci": "c" | |
}, | |
"10mat5": { | |
"id": "10mat5", | |
"noPertanyaan": 5, | |
"pertanyaan": "", | |
"jawaban": { | |
"a": "", | |
"b": "", | |
"c": "", | |
"d": "" | |
}, | |
"kunci": "b" | |
}, | |
"10mat6": { | |
"id": "10mat6", | |
"noPertanyaan": 6, | |
"pertanyaan": "", | |
"jawaban": { | |
"a": "", | |
"b": "", | |
"c": "", | |
"d": "" | |
}, | |
"kunci": "d" | |
}, | |
"10mat7": { | |
"id": "10mat7", | |
"noPertanyaan": 7, | |
"pertanyaan": "", | |
"jawaban": { | |
"a": "", | |
"b": "", | |
"c": "", | |
"d": "" | |
}, | |
"kunci": "e" | |
}, | |
"10mat8": { | |
"id": "10mat8", | |
"noPertanyaan": 8, | |
"pertanyaan": "", | |
"jawaban": { | |
"a": "", | |
"b": "", | |
"c": "", | |
"d": "" | |
}, | |
"kunci": "b" | |
}, | |
"10mat9": { | |
"id": "10mat9", | |
"noPertanyaan": 9, | |
"pertanyaan": "", | |
"jawaban": { | |
"a": "", | |
"b": "", | |
"c": "", | |
"d": "" | |
}, | |
"kunci": "c" | |
}, | |
"10mat10": { | |
"id": "10mat10", | |
"noPertanyaan": 10, | |
"pertanyaan": "", | |
"jawaban": { | |
"a": "", | |
"b": "", | |
"c": "", | |
"d": "" | |
}, | |
"kunci": "e" | |
}, | |
"10mat11": { | |
"id": "10mat11", | |
"noPertanyaan": 11, | |
"pertanyaan": "", | |
"jawaban": { | |
"a": "", | |
"b": "", | |
"c": "", | |
"d": "" | |
}, | |
"kunci": "3" | |
}, | |
"10mat12": { | |
"id": "10mat12", | |
"noPertanyaan": 12, | |
"pertanyaan": "", | |
"jawaban": { | |
"a": "", | |
"b": "", | |
"c": "", | |
"d": "" | |
}, | |
"kunci": "d" | |
}, | |
"10mat13": { | |
"id": "10mat13", | |
"noPertanyaan": 13, | |
"pertanyaan": "", | |
"jawaban": { | |
"a": "", | |
"b": "", | |
"c": "", | |
"d": "" | |
}, | |
"kunci": "c" | |
}, | |
"10mat14": { | |
"id": "10mat14", | |
"noPertanyaan": 14, | |
"pertanyaan": "", | |
"jawaban": { | |
"a": "", | |
"b": "", | |
"c": "", | |
"d": "" | |
}, | |
"kunci": "a" | |
}, | |
"10mat15": { | |
"id": "10mat15", | |
"noPertanyaan": 15, | |
"pertanyaan": "", | |
"jawaban": { | |
"a": "", | |
"b": "", | |
"c": "", | |
"d": "" | |
}, | |
"kunci": "e" | |
}, | |
"10mat16": { | |
"id": "10mat16", | |
"noPertanyaan": 16, | |
"pertanyaan": "", | |
"jawaban": { | |
"a": "", | |
"b": "", | |
"c": "", | |
"d": "" | |
}, | |
"kunci": "d" | |
}, | |
"10mat17": { | |
"id": "10mat17", | |
"noPertanyaan": 17, | |
"pertanyaan": "", | |
"jawaban": { | |
"a": "", | |
"b": "", | |
"c": "", | |
"d": "" | |
}, | |
"kunci": "c" | |
}, | |
"10mat18": { | |
"id": "10mat18", | |
"noPertanyaan": 18, | |
"pertanyaan": "", | |
"jawaban": { | |
"a": "", | |
"b": "", | |
"c": "", | |
"d": "" | |
}, | |
"kunci": "b" | |
}, | |
"10mat19": { | |
"id": "10mat19", | |
"noPertanyaan": 19, | |
"pertanyaan": "", | |
"jawaban": { | |
"a": "", | |
"b": "", | |
"c": "", | |
"d": "" | |
}, | |
"kunci": "d" | |
}, | |
"10mat20": { | |
"id": "10mat20", | |
"noPertanyaan": 20, | |
"pertanyaan": "", | |
"jawaban": { | |
"a": "", | |
"b": "", | |
"c": "", | |
"d": "" | |
}, | |
"kunci": "c" | |
} | |
} | |
module.exports = objek |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const file = require('./10-matematika.js') | |
const modul = JSON.parse(JSON.stringify(file)) | |
// let str = (s => s.raw), require('./soal/10-matematika.js') | |
// delete modul.subjek; | |
// // modul.forEach(element => { | |
// // console.log(element) | |
// // }) | |
// for (const soal in modul) { | |
// if (modul.hasOwnProperty(soal) && modul[soal].id !== undefined) { | |
// // kumpulanKunci.push({ | |
// // id: modul[soal].id, | |
// // kunci: modul[soal].kunci | |
// // }) | |
// // delete modul[soal].kunci | |
// // modul[soal].jawaban.forEach(element => { | |
// // console.log(element) | |
// // }); | |
// Object.entries(modul[soal].jawaban).forEach(([key, val]) => { | |
// // console.log(modul[soal].jawaban[key], modul[soal].jawaban[val]) | |
// console.log(key, val) | |
// // modul[soal].jawaban[key] = `${JSON.parse(JSON.stringify(val))}` | |
// modul[soal].jawaban[key] = String.raw`${val}` | |
// }) | |
// } | |
// } | |
console.log(modul) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment