Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1 @@
gw.lang.reflect.json.Json#fromJson( String json ) : javax.script.Bindings

View file

@ -0,0 +1,20 @@
{
"Name": "Dickson Yamada",
"Age": 39,
"Address": {
"Number": 9604,
"Street": "Donald Court",
"City": "Golden Shores",
"State": "FL"
},
"Hobby": [
{
"Category": "Sport",
"Name": "Baseball"
},
{
"Category": "Recreation",
"Name": "Hiking"
}
]
}

View file

@ -0,0 +1,3 @@
var personUrl = new URL( "http://gosu-lang.github.io/data/person.json" )
var person: Dynamic = personUrl.JsonContent
print( person.Name )

View file

@ -0,0 +1 @@
personUrl.JsonContent

View file

@ -0,0 +1 @@
print( person.toStructure( "Person", false ) )

View file

@ -0,0 +1,28 @@
structure Person {
static function fromJson( jsonText: String ): Person {
return gw.lang.reflect.json.Json.fromJson( jsonText ) as Person
}
static function fromJsonUrl( url: String ): Person {
return new java.net.URL( url ).JsonContent
}
static function fromJsonUrl( url: java.net.URL ): Person {
return url.JsonContent
}
static function fromJsonFile( file: java.io.File ) : Person {
return fromJsonUrl( file.toURI().toURL() )
}
property get Address(): Address
property get Hobby(): List<Hobby>
property get Age(): Integer
property get Name(): String
structure Address {
property get Number(): Integer
property get State(): String
property get Street(): String
property get City(): String
}
structure Hobby {
property get Category(): String
property get Name(): String
}
}

View file

@ -0,0 +1,4 @@
var person = Person.fromJsonUrl( personUrl )
print( person.Name )
print( person.Address.City )
print( person.Hobby[0].Name )

View file

@ -0,0 +1,3 @@
print( person.toJson() ) // toJson() generates the Expando bindings to a JSON string
print( person.toGosu() ) // toGosu() generates any Bindings instance to a Gosu Expando initializer string
print( person.toXml() ) // toXml() generates any Bindings instance to standard XML

View file

@ -0,0 +1 @@
var clone = eval( person.toGosu() )