The following code in Python:
jsVar = (json.dumps(jsPass))
produces this output:
{
"TT1004": [
[1004, 45.296109039999997, -75.926546579999993,
66.996664760000002, 150, false
]
],
"TT1001": [
[1001, 45.296471220000001, -75.923881289999997, 64.616423409999996, 150, false]
],
"TT1003": [
[1003, 45.296109379999997, -75.926543379999998,
67.240025419999995, 150, false
]
],
"TT1002": [
[1002, 45.29626098, -75.924908610000003, 65.300880480000004, 150, true]
]
}
The output passes validation on the JSON Formatter & Validator website.
In the JavaScript code I’ve set the following:
var myVar2 = {};
var myVar2 = jsVar;
When I look at the output of the console.log
or .dir
methods for the JavaScript variable myVar2
, there is no data. It returns Object { }
along with an empty __proto__:Object
.
In order to test that the Python data that is generated is correct JS, I have manually placed the data into the JavaScript variable which logs the following:
{
TT1004: Array[1],
TT1001: Array[1],
TT1003: Array[1],
TT1002: Array[1]
}
What I need to learn is how to import the Python JSON jsVar variable into the JavaScript Code.