If you use es6 you can use
import street from "./data/street.json";
where street is your geojson file
and then use L.geoJSON(street).addTo(map)
Here is an es6 example with a geojson to see it live.
Edit
Without using es6 what you need to do is:
Having created a folder data and a file street.json you need to store the json inside street.json with a variable for instance
var street = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[-105.00341892242432, 39.75383843460583],
[-105.0008225440979, 39.751891803969535]
]
},
...
}
and then import it on index.html as
<script src="./data/street.json"></script>
inside <body>
.
Make sure you create the folder inside the root of your project.
Therefore you would have something like this in your body:
<body>
<div id="map"></div>
<script src="./data/street.json"></script>
<script src="script.js"></script>
</body>
and then reference it with the variable street you defined inside street.json
:
L.geoJSON(street).addTo(map)
plain js demo