string-to-json-converter
npm install string-to-json-converterString to Json converter
==============
Convert a string that contains a Json object to Json object format. This can convert json object that have arrays inside and keys with dot notation. Mainly focusing on MongoDB queries.
``js
For example
This will convert string like this to '{ appName: "JsonTest", keywords: { $in: [ "json", "string" ] } }'
Object like below
{
appName: 'JsonTest',
keywords: {
$in: [ 'json', 'string' ]
}
}
`
-------------
`js
import StringToJson from 'string-to-json-converter';
const jsonString = '{ appName: "JsonTest", keywords: { $in: [ "json", "string" ] } }';
// IMPORTANT - String should provide within single quotes. String inside the object should provide within double quotes.
const resultJsonObject = await StringToJson.convertJson(jsonString);
``