租房小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
388 B

6 months ago
  1. export function policy2Str(policy: string | object) {
  2. let policyStr;
  3. if (policy) {
  4. if (typeof policy === 'string') {
  5. try {
  6. policyStr = JSON.stringify(JSON.parse(policy));
  7. } catch (err) {
  8. throw new Error(`Policy string is not a valid JSON: ${err.message}`);
  9. }
  10. } else {
  11. policyStr = JSON.stringify(policy);
  12. }
  13. }
  14. return policyStr;
  15. }