let jpathExpression_js: string = "data.records[0].id";
let jpathExpression_points_joined: string = "data.records.0.id";
let jpathExpression_jsonkey_ext_symbols: string = "[data][records][0][field 2]";
In HTML
<!-- 💡 In `.html` for the 'js framework like' Reactivity by central json data in a SPA. -->
<html>
...
<div data-jpath="data.records.0.id"></div>
...
<script src="node_modules/@jaisocx/jpath/transpiled/Simple/JPathData.js"></script>
<script src="node_modules/@jaisocx/jpath/transpiled/Simple/JPath.js"></script>
<script>
// DOMContentLoaded ...
</script>
</html>
Typescript
let obj: any = {
"data": {
"records": [
{ "id": 1, "field 2": "text line of field 2" }
]
}
};
let jPath: JPath = new JPath();
let jpathExpression: string = "data.records[0][field 2]";
let field2: any = jPath.getByJPathExpression( obj, jpathExpression );
console.log ( field2 );
// $ _ text line of field 2