Loading...
Searching...
No Matches
juce::JSONUtils Struct Reference

## Detailed Description

A mini namespace to hold utility functions for working with juce::vars.

The documentation for this struct was generated from the following file:

- juce_core/json/juce_JSONUtils.h

## Public Member Functions

| JSONUtils ()=delete
| No constructor.

## Static Public Member Functions

static std::optional< var > | getPointer (const var &v, String pointer)
| Given a JSON array/object 'v' and a string representing a JSON pointer this returns a copy of the value referenced by 'pointer'.
static std::optional< var > | setPointer (const var &v, String pointer, const var &newValue)
| Given a JSON array/object 'v', a string representing a JSON pointer, and a new property value 'newValue', returns a copy of 'v' where the property or array index referenced by the pointer has been set to 'newValue'.
static var | makeObject (const std::map< Identifier, var > &source)
| Converts the provided key/value pairs into a JSON object.
static var | makeObjectWithKeyFirst (const std::map< Identifier, var > &source, Identifier key)
| Converts the provided key/value pairs into a JSON object with the provided key at the first position in the object.
static bool | deepEqual (const var &a, const var &b)
| Returns true if and only if the contents of a match the contents of b.

## Constructors and Destructors

## JSONUtils()

juce::JSONUtils::JSONUtils | ( |  | ) |

delete

No constructor.

## Member Functions

## getPointer()

std::optional< var > juce::JSONUtils::getPointer | ( | const var & | v,
|  | String | pointer )

static

Given a JSON array/object 'v' and a string representing a JSON pointer this returns a copy of the value referenced by 'pointer'.

If the pointer cannot be followed, due to referencing missing array indices or fields, then this returns nullopt.

For more details, check the JSON Pointer RFC 6901: https://datatracker.ietf.org/doc/html/rfc6901

## setPointer()

std::optional< var > juce::JSONUtils::setPointer | ( | const var & | v,
|  | String | pointer,
|  | const var & | newValue )

static

Given a JSON array/object 'v', a string representing a JSON pointer, and a new property value 'newValue', returns a copy of 'v' where the property or array index referenced by the pointer has been set to 'newValue'.

If the pointer cannot be followed, due to referencing missing array indices or fields, then this returns nullopt.

For more details, check the JSON Pointer RFC 6901: https://datatracker.ietf.org/doc/html/rfc6901

## makeObject()

var juce::JSONUtils::makeObject | ( | const std::map< Identifier, var > & | source | ) |

static

Converts the provided key/value pairs into a JSON object.

## makeObjectWithKeyFirst()

var juce::JSONUtils::makeObjectWithKeyFirst | ( | const std::map< Identifier, var > & | source,
|  | Identifier | key )

static

Converts the provided key/value pairs into a JSON object with the provided key at the first position in the object.

This is useful because the MIDI-CI spec requires that certain fields (e.g. status) should be placed at the beginning of a MIDI-CI header.

## deepEqual()

bool juce::JSONUtils::deepEqual | ( | const var & | a,
|  | const var & | b )

static

Returns true if and only if the contents of a match the contents of b.

Unlike var::operator==, this will recursively check that contained DynamicObject and Array instances compare equal.

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited