turnjson

JSON对象key值替换,value值替换

Usage no npm install needed!

<script type="module">
  import turnjson from 'https://cdn.skypack.dev/turnjson';
</script>

README

JSON对象key值替换,value值替换

Input

{
    "click": "点击",
    "name": "名字"
    "name": "name"
}

Output

{ 
    '点击': '点击',
    '名字': '名字',
    '名字': '名字'
}

Example

const clickMap = {
    "click": "点击",
    "name": "名字"
}
const source = {
    "click": "点击",
    "name": "名字"
}
const turn = require('./').turn
const result = turn(source, clickMap)
console.log(result) //{"点击":"点击","名字":"名字"}