1 /*---------------------------------------------------------------------------------------------
2 * Copyright (c) Microsoft Corporation. All rights reserved.
3 * Licensed under the MIT License. See License.txt in the project root for license information.
4 *--------------------------------------------------------------------------------------------*/
5 export function stringifyObject(obj, indent, stringifyLiteral) {
6 if (obj !== null && typeof obj === 'object') {
7 var newIndent = indent + '\t';
8 if (Array.isArray(obj)) {
9 if (obj.length === 0) {
13 for (var i = 0; i < obj.length; i++) {
14 result += newIndent + stringifyObject(obj[i], newIndent, stringifyLiteral);
15 if (i < obj.length - 1) {
20 result += indent + ']';
24 var keys = Object.keys(obj);
25 if (keys.length === 0) {
29 for (var i = 0; i < keys.length; i++) {
31 result += newIndent + JSON.stringify(key) + ': ' + stringifyObject(obj[key], newIndent, stringifyLiteral);
32 if (i < keys.length - 1) {
37 result += indent + '}';
41 return stringifyLiteral(obj);