-
Notifications
You must be signed in to change notification settings - Fork 0
JObject
JSON Object, holding a list of JSON JTokens referenced by property names
public class JObject : QuickJSON.JToken,
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, QuickJSON.JToken>>,
System.Collections.IEnumerable
Inheritance System.Object 🡒 JToken 🡒 JObject
Implements System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String,JToken>>, System.Collections.IEnumerable
Makes an empty JObject
public JObject();
Makes an clone of another JObject
public JObject(QuickJSON.JObject other);
other
JObject
Makes an JObject with property names and values from an IDictionary
public JObject(System.Collections.IDictionary dict);
dict
System.Collections.IDictionary
Get number of properties
public override int Count { get; }
Access JToken by string property key
Returns JToken found by property key, or null if not present or indexer is not a string
public override QuickJSON.JToken this[object key] { get; set; }
key
System.Object
System.InvalidCastException
If name is not of type string on set
Access JToken by string indexer
Returns JToken found by indexer, or null if not present
public QuickJSON.JToken this[string key] { get; set; }
key
System.String
Add a JToken with this property name. Will overwrite any existing property
public override void Add<T>(string key, T o);
key
System.String
o
T
Add a JToken with this property name. Will overwrite any existing property
public override void Add(string key, QuickJSON.JToken value);
key
System.String
value
JToken
Clear all properties
public override void Clear();
Does the JObject contain property name
public override bool Contains(string name);
name
System.String
Does the JObject contain any of these properties, if so return first one found, else return null
public QuickJSON.JToken Contains(string[] ids);
ids
System.String[]
Does the JObject contain all the listed properties
public bool ContainsAllOfThese(params string[] name);
name
System.String[]
Does the JObject contain one of these?
public bool ContainsAnyOf(params string[] name);
name
System.String[]
Does the JObject contain one of these? -1 no, else first one found.
public int ContainsIndexOf(out QuickJSON.JToken ret, params string[] name);
ret
JToken
name
System.String[]
Does the JObject contain one of these? -1 no, else first one found.
public int ContainsIndexOf(params string[] name);
name
System.String[]
Filter this object into a return object.
Allowed fields are a set of object key/value pairs with the value set to:
Boolean true/false: direct allow/disallow of any type with this field name
JArray containing one JOBJECT: item is an array of objects, with the allowed fields in that object listed:
["name"] = new JArray
{ new JObject
{
["Null"] = true,
["Star"] = true,
["Planet"] = true,
["Ring"] = true
} }
or
["name"] = "[]" - Allow anything in an array
JObject: allow an object with these fields present if boolean is true.
["name"] = new JObject
{
["Rock"] = true,
["Metal"] = true,
},
public QuickJSON.JObject Filter(QuickJSON.JObject allowedFields, string path="");
allowedFields
JObject
A JObject of allowed fields to keep
path
System.String
path is used to track the object names through the heirachy for diagnostics purposes only. Do not set.
JObject
Clone of JToken with allowed fields only
Get the first JToken
public override QuickJSON.JToken First();
System.ArgumentOutOfRangeException
If no items are present
Get the first JToken or null if no properties are present
public override QuickJSON.JToken FirstOrDefault();
Key Value Pair Enumerator
public System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<string,QuickJSON.JToken>> GetEnumerator();
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<System.String,JToken>>
Implements GetEnumerator(), GetEnumerator()
Get the last JToken
public override QuickJSON.JToken Last();
System.ArgumentOutOfRangeException
If no items are present
Get the last JToken or null if no properties are present
public override QuickJSON.JToken LastOrDefault();
Merge two objects together, with overwrite protection
public void Merge(QuickJSON.JObject other, bool allowoverwrite=true);
other
JObject
Other JObject to merge into this
allowoverwrite
System.Boolean
Allows overwriting of this object members with other
Parse the JSON string presuming it will return an JObject
public static QuickJSON.JObject Parse(string text, QuickJSON.JToken.ParseOptions flags=QuickJSON.JToken.ParseOptions.None);
text
System.String
Text to parse
flags
ParseOptions
Parsing flags, default None
JObject
JObject or null if parse fails or does not return a JObject
JsonException
Thrown on error if parse flags indicate exception required. Error will be in exception Error value.
Parse the JSON string presuming it will return an JObject
public static QuickJSON.JObject Parse(string text, out string error, QuickJSON.JToken.ParseOptions flags);
text
System.String
Text to parse
error
System.String
Null if no error, else error string
flags
ParseOptions
Parsing flags
JObject
JObject or null if parse fails or does not return a JObject
JsonException
Thrown on JSON parse error if parse flags indicate exception required. Error will be in exception Error value
Parse the JSON string presuming it will return an JObject
Parsing flags are set to AllowTrailingCommas | CheckEOL | ThrowOnError
public static QuickJSON.JObject ParseThrowCommaEOL(string text);
text
System.String
Text to parse
JObject
JObject or null if parse fails or does not return a JObject
JsonException
Thrown on error. Error will be in exception Error value.
Get an array of all property names
public string[] PropertyNames();
Remove a JToken with this property name. True if found, false if not
public bool Remove(string key);
key
System.String
Remove JTokens with these property names.
public void Remove(params string[] key);
key
System.String[]
Remove JTokens with these property names.
public void RemoveWildcard(string wildcard, bool caseinsensitive=false);
wildcard
System.String
Property name to find. May contain * and ? wildcards
caseinsensitive
System.Boolean
True if case insensitive match
Rename a field to newname. Returns true if done. If newname already exists it is overwritten.
public bool Rename(string fromname, string newname);
fromname
System.String
Name to rename
newname
System.String
New name
System.Boolean
true if fromname exists.
Get a JToken by this property name
public bool TryGetValue(string name, out QuickJSON.JToken token);
name
System.String
Name of property
token
JToken
Where to store the found JToken
System.Boolean
If property is not found, return false (null in token), else return true (token has found item)
Return other property names not in this list
public System.Collections.Generic.IEnumerable<string> UnknownProperties(params string[] name);
name
System.String[]
System.Collections.Generic.IEnumerable<System.String>
Return other property names not in this pair of lists
public System.Collections.Generic.IEnumerable<string> UnknownProperties(string[] name, params string[] name2);
name
System.String[]
name2
System.String[]