
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
jsonpathmap
Advanced tools
"# jsonpathmapper"
Small utility for mapping javascript object data into jsonpath-description based structure.
Usage: const myResult2 = jsonpathmap2.jsonpathmap2(extract, data);
Example:
Let's say this is data.
const _mydata = {
type: 'fruit',
list: [
{
name: 'apple',
taste: 'best'
},
{
name: 'banana',
taste: 'wow'
},
{
name: 'mango',
taste: 'delicious'
}
]
}
And this is target structure
const _myTargetStructure = {
type: '$.type',
count: '%.list[0,1]',
list: [
{
name: '$.list[0,1].name'
}
],
fullcount: '#.list[*]',
fulllist: [
{
name: '$.list[*].name',
taste: '$.list[*].taste',
}
]
}
jsonpathmap will produce following result
{
"type": "fruit",
"count": 2,
"list": [
{
"name": "apple"
},
{
"name": "banana"
}
],
{
"name": [
"apple",
"banana"
]
}
],
"fullcount": "3",
"fulllist": [
{
"name": "apple",
"taste": "best"
},
{
"name": "banana",
"taste": "wow"
},
{
"name": "mango",
"taste": "delicous"
}
]
}
can use full JSONPath expressions: see https://www.npmjs.com/package/jsonpath
$. denotes jsonpath notation
#. denotes jsonpath notation's count in string
%. denotes jsonpath notation's count in number
NEW Special notation of [!]
Let's say this is data.
const data = {
type: 'fruit',
list: [
{
name: 'apple',
rating: 10,
metadata: {
color: 'red',
size: 'middle',
records: [
{
year: 2020,
rating: 10
},
{
year: 2021,
rating: 8
},
{
year: 2022,
rating: 6
},
]
}
},
{
name: 'mango',
rating: 6,
metadata: {
color: 'yellow',
size: 'big',
records: [
{
year: 2020,
rating: 7
},
{
year: 2021,
rating: 5
},
{
year: 2022,
rating: 3
},
]
}
},
{
name: 'grape',
rating: 8,
metadata: {
color: 'violet',
size: 'small',
records: [
{
year: 2020,
rating: 4
},
{
year: 2021,
rating: 4
},
{
year: 2022,
rating: 2
},
]
}
}
]
}
and query is as follows;
const extract = {
count: '%.list[*].name',
stringCount: '#.list[*].name',
fruits: [
{
name: '$.list[*].name',
rating: '$.list[*].rating',
recordsFor2022: '$.list[*].metadata.records[?(@.year === 2022)].rating',
test: [
{
item1: '$.list[!].metadata.records[*].rating',
item2: '$.list[!].metadata.records[*].year',
}
]
}
]
}
result will be ([!] iterate within node only)
{
"count": 3,
"stringCount": "3",
"fruits": [
{
"name": "apple",
"rating": 10,
"recordsFor2022": 6,
"test": [
{
"item1": 10,
"item2": 2020
},
{
"item1": 8,
"item2": 2021
},
{
"item1": 6,
"item2": 2022
}
]
},
{
"name": "mango",
"rating": 6,
"recordsFor2022": 3,
"test": [
{
"item1": 7,
"item2": 2020
},
{
"item1": 5,
"item2": 2021
},
{
"item1": 3,
"item2": 2022
}
]
},
{
"name": "grape",
"rating": 8,
"recordsFor2022": 2,
"test": [
{
"item1": 4,
"item2": 2020
},
{
"item1": 4,
"item2": 2021
},
{
"item1": 2,
"item2": 2022
}
]
}
]
}
FAQs
jsonpmap utility. By starlog(Felix Cho)
The npm package jsonpathmap receives a total of 2 weekly downloads. As such, jsonpathmap popularity was classified as not popular.
We found that jsonpathmap demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.