Report a bug
		
				If you spot a problem with this page, click here to create a GitHub issue.
		
			Improve this page
		
			Quickly fork, edit online, and submit a pull request for this page.
			Requires a signed-in GitHub account. This works well for small changes.
			If you'd like to make larger changes you may want to consider using
			a local clone.
		
	asdf.transform
Mutable ASDF data structure.
The representation can be used to compute a difference between JSON object-trees.
Authors: 
Ilya Yaroshenko
License: 
BSL-1.0
- structAsdfNode;
- Object-tree structure for mutable Asdf representation.AsdfNodecan be used to construct and manipulate JSON objects. EachAsdfNodecan represent either a dynamic JSON object (associative array ofAsdfNodenodes) or a ASDF JSON value. JSON arrays can be represented only as JSON values.- AsdfNode[const(char)[]]children;
- Children nodes.
- Asdfdata;
- Leaf data.
- const pure nothrow @nogc @safe boolisLeaf();
- Returns true if the node is leaf.
- pure this(Asdfdata);
- Construct AsdfNode recursively.
- pure ref scope AsdfNodeopIndex(scope const(char)[][]keys...) return;
- Examples:import asdf; auto text = `{"foo":"bar","inner":{"a":true,"b":false,"c":"32323","d":null,"e":{}}}`; auto root = AsdfNode(text.parseJson); assert(root["inner", "a"].data == `true`.parseJson); 
- pure voidopIndexAssign(AsdfNodevalue, scope const(char)[][]keys...);
- Examples:import asdf; auto text = `{"foo":"bar","inner":{"a":true,"b":false,"c":"32323","d":null,"e":{}}}`; auto root = AsdfNode(text.parseJson); auto value = AsdfNode(`true`.parseJson); root["inner", "g", "u"] = value; assert(root["inner", "g", "u"].data == true); 
- pure AsdfNodeget(AsdfNodevalue, in char[][]keys...);
- Parameters:AsdfNode valuedefault value char[][] keyslist of keys Returns:[keys] if any andvalueothervise.Examples:import asdf; auto text = `{"foo":"bar","inner":{"a":true,"b":false,"c":"32323","d":null,"e":{}}}`; auto root = AsdfNode(text.parseJson); auto value = AsdfNode(`false`.parseJson); assert(root.get(value, "inner", "a").data == true); assert(root.get(value, "inner", "f").data == false); 
- pure voidserialize(ref AsdfSerializerserializer);
- Serialization primitive
- AsdfopCast(T : Asdf)();
- Examples:import asdf; auto text = `{"foo":"bar","inner":{"a":true,"b":false,"c":"32323","d":null,"e":{}}}`; auto root = AsdfNode(text.parseJson); import std.stdio; Asdf flat = cast(Asdf) root; assert(flat["inner", "a"] == true); 
- const pure nothrow @nogc @safe boolopEquals(in AsdfNoderhs);
- Examples:import asdf; auto text = `{"foo":"bar","inner":{"a":true,"b":false,"c":"32323","d":null,"e":{}}}`; auto root1 = AsdfNode(text.parseJson); auto root2= AsdfNode(text.parseJson); assert(root1 == root2); assert(root1["inner"].children.remove("b")); assert(root1 != root2); 
- pure voidadd(Asdfdata);
- Adds data to the object-tree recursively.Examples:import asdf; auto text = `{"foo":"bar","inner":{"a":true,"b":false,"c":"32323","d":null,"e":{}}}`; auto addition = `{"do":"re","inner":{"a":false,"u":2}}`; auto root = AsdfNode(text.parseJson); root.add(addition.parseJson); auto result = `{"do":"re","foo":"bar","inner":{"a":false,"u":2,"b":false,"c":"32323","d":null,"e":{}}}`; assert(root == AsdfNode(result.parseJson)); 
- pure voidremove(Asdfdata);
- Removes keys from the object-tree recursively.Examples:import asdf; auto text = `{"foo":"bar","inner":{"a":true,"b":false,"c":"32323","d":null,"e":{}}}`; auto rem = `{"do":null,"foo":null,"inner":{"c":null,"e":null}}`; auto root = AsdfNode(text.parseJson); root.remove(rem.parseJson); auto result = `{"inner":{"a":true,"b":false,"d":null}}`; assert(root == AsdfNode(result.parseJson)); 
- pure Asdfremoved(AsdfNodenode);
- Returns the subset of the object-tree which is not represented innode. If a leaf is represented but has a different value then it will be included in the return value. Returned value has ASDF format and its leaves are set to null.Examples:import asdf; auto text1 = `{"inner":{"a":true,"b":false,"d":null}}`; auto text2 = `{"foo":"bar","inner":{"a":false,"b":false,"c":"32323","d":null,"e":{}}}`; auto node1 = AsdfNode(text1.parseJson); auto node2 = AsdfNode(text2.parseJson); auto diff = AsdfNode(node2.removed(node1)); assert(diff == AsdfNode(`{"foo":null,"inner":{"a":null,"c":null,"e":null}}`.parseJson)); 
- pure Asdfadded(AsdfNodenode);
- Returns the subset of the node which is not represented in the object-tree. If a leaf is represented but has a different value then it will be included in the return value. Returned value has ASDF format.Examples:import asdf; auto text1 = `{"foo":"bar","inner":{"a":false,"b":false,"c":"32323","d":null,"e":{}}}`; auto text2 = `{"inner":{"a":true,"b":false,"d":null}}`; auto node1 = AsdfNode(text1.parseJson); auto node2 = AsdfNode(text2.parseJson); auto diff = AsdfNode(node2.added(node1)); assert(diff == AsdfNode(`{"foo":"bar","inner":{"a":false,"c":"32323","e":{}}}`.parseJson)); 
 
Copyright © 2016-2022 by Ilya Yaroshenko | Page generated by
Ddoc on Thu Mar 24 03:41:37 2022