Skip to content
/ ason Public

Ason, Array Script Object Notation, a lightweight dynamic object initiation format

License

Notifications You must be signed in to change notification settings

iboxdb/ason

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Ason

Ason is a dynamic object notation by using Array. the definition is simple, if the first element of the Array ends with ':', this Array is a representation of Key-Value pairs.

Getting Started

import static iboxdb.localserver.Ason.*;

public class AsonExample {
     
    public static void main(String[] args)
    {
        var obj = ason("Name:", "Andy", "Value:", 100);
                
        System.out.println(obj.getClass());
        System.out.println(obj);
    }
}

Output

class java.util.HashMap
{Value=100, Name=Andy}
Hiberarchy
var obj = ason("Name:", "Andy", "Value:", ason( "SubName:", "SubAndy" ) );

Output

{Value={SubName=SubAndy}, Name=Andy}
Use class Ason can call a function
import iboxdb.localserver.*;
import static iboxdb.localserver.Ason.*;
import static iboxdb.localserver.IFunction.*;

public class AsonExample {

    public static void main(String[] args) {
        var obj = new Ason("Name:", "Andy", "Add:", func((inputs) -> {
            return (Integer) inputs[0] + (Integer) inputs[1];
        }));
 
        System.out.println(obj.invoke("Add", 100, 200));
    }
}

the Array passed through "new Ason(array)" always dynamic object array, it doesn't check the ':' flag.

if the first element not ends with ':' , it will back to Array , as "new Object[]"

var obj = new Ason("Name:", "Andy", "Addresses:", ason("Addr_01", "Addr_02"));

Object[] os = (Object[]) obj.get("Addresses");
System.out.println(os[0] + " , " + os[1]);

if an Array ends with ':', but it isn't dynamic object, just new an Array,

var obj = new Object[]{ "ABC:", "DEF:"};

About

Ason, Array Script Object Notation, a lightweight dynamic object initiation format

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages