public string ToJsonString(int indentDelta, int maxIndentLevel, bool noCommas, bool noQuotes)
            {
                jtb           = new JsonTextBuffer(indentDelta, maxIndentLevel, noCommas);
                this.noQuotes = noQuotes;
                DoJsonStruct(this);

                return(jtb.ToString().Dequoted());
            }
Example #2
0
        public static string FormatJson(BaseTerm jsonTerm)
        {
            JsonTextBuffer result = new JsonTextBuffer();

            if (jsonTerm.FunctorToString == PrologParser.CURL)
            {
                DoJsonObject0(result, null, jsonTerm, true);
            }
            else if (jsonTerm is AltListTerm) // if {...} has been declared a last with wrap( '{', |, '}')
            {
                DoJsonObject0(result, null, (AltListTerm)jsonTerm, true);
            }
            else if (jsonTerm.IsProperList)
            {
                DoJsonArray0(result, null, ((ListTerm)jsonTerm), true);
            }
            else
            {
                IO.Error("Error in JSON term:\r\n{0}", jsonTerm);
            }

            return(result.ToString());
        }