Loading...
Searching...
No Matches
juce_JSON.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
class JUCE_API JSON
{
public:
//==============================================================================
static Result parse (const String& text, var& parsedResult);
static var parse (const String& text);
static var parse (const File& file);
static var parse (InputStream& input);
enum class Spacing
{
none,
singleLine,
multiLine,
};
class [[nodiscard]] FormatOptions
{
public:
FormatOptions withSpacing (Spacing x) const { return withMember (*this, &FormatOptions::spacing, x); }
FormatOptions withMaxDecimalPlaces (int x) const { return withMember (*this, &FormatOptions::maxDecimalPlaces, x); }
FormatOptions withIndentLevel (int x) const { return withMember (*this, &FormatOptions::indent, x); }
Spacing getSpacing() const { return spacing; }
int getMaxDecimalPlaces() const { return maxDecimalPlaces; }
int getIndentLevel() const { return indent; }
private:
Spacing spacing = Spacing::multiLine;
int maxDecimalPlaces = 15;
int indent = 0;
};
//==============================================================================
static String toString (const var& objectToFormat,
bool allOnOneLine = false,
int maximumDecimalPlaces = 15);
static String toString (const var& objectToFormat,
const FormatOptions& formatOptions);
static var fromString (StringRef);
static void writeToStream (OutputStream& output,
const var& objectToFormat,
bool allOnOneLine = false,
int maximumDecimalPlaces = 15);
static void writeToStream (OutputStream& output,
const var& objectToFormat,
const FormatOptions& formatOptions);
static String escapeString (StringRef);
static Result parseQuotedString (String::CharPointerType& text, var& result);
private:
//==============================================================================
JSON() = delete; // This class can't be instantiated - just use its static methods.
};
} // namespace juce
juce::File
Definition juce_File.h:45
juce::InputStream
Definition juce_InputStream.h:37
juce::JSON::FormatOptions
Definition juce_JSON.h:102
juce::JSON::FormatOptions::getIndentLevel
int getIndentLevel() const
Definition juce_JSON.h:124
juce::JSON::FormatOptions::getSpacing
Spacing getSpacing() const
Definition juce_JSON.h:118
juce::JSON::FormatOptions::getMaxDecimalPlaces
int getMaxDecimalPlaces() const
Definition juce_JSON.h:121
juce::JSON::FormatOptions::withSpacing
FormatOptions withSpacing(Spacing x) const
Definition juce_JSON.h:105
juce::JSON::FormatOptions::withIndentLevel
FormatOptions withIndentLevel(int x) const
Definition juce_JSON.h:115
juce::JSON::FormatOptions::withMaxDecimalPlaces
FormatOptions withMaxDecimalPlaces(int x) const
Definition juce_JSON.h:110
juce::JSON
Definition juce_JSON.h:39
juce::JSON::parse
static Result parse(const String &text, var &parsedResult)
Definition juce_JSON.cpp:499
juce::JSON::Spacing
Spacing
Definition juce_JSON.h:92
juce::JSON::Spacing::multiLine
@ multiLine
Newlines and spaces will be included in the output, in order to make it easy to read for humans.
Definition juce_JSON.h:95
juce::OutputStream
Definition juce_OutputStream.h:38
juce::Result
Definition juce_Result.h:57
juce::StringRef
Definition juce_StringRef.h:62
juce::String
Definition juce_String.h:53
juce::var
Definition juce_Variant.h:42