model.json-generated.tdltx 2.19 KB
Newer Older
Philip Makedonski's avatar
Philip Makedonski committed
Package generated_from_model_json {
    Type String
    Type TODO_RESOLVE_REFERENCED
    Use "model.json" as SOURCE_MAPPING
    Type JSON_String
    Structure JSON_model_json (
        JSON_authors authors,
        JSON_books books
    )
    Collection JSON_authors of JSON_authors_item
    Structure JSON_authors_item (
        JSON_String name
    )
    Collection JSON_books of JSON_books_item
    Structure JSON_books_item (
        JSON_String title,
        JSON_authors authors,
        JSON_String year
    )
    
    JSON_books_item b2 (
        title = "Instance Book 2"
    )
    
Philip Makedonski's avatar
Philip Makedonski committed
    JSON_model_json JSON_instance (
        authors = [
            (
                name = "Alfonso"
            ),
            (
                name = "Alfred"
            )
        ],
        books = [
            (
                title = "Book One",
                authors = [
                    (
                        name = "Author One"
                    ),
                    (
                        name = "Author Two"
                    )
                ]
            ),
            (
                title = "Book Two",
                authors = [
                    (
                        name = "Alfonso"
                    )
                ]
            ),
            (
                title = "Book Three",
                year = "2022",
                authors = [
                    (
                        name = "Alfred"
                    )
                ]
            ),
            b2 (),
            b2 (
            	year = "2023"
            ),
            b2 (
            	title = "2023 override"
            ),
            b2 (
            	title = "2023 override and extra year",
            	year = "2023"
            ),
Philip Makedonski's avatar
Philip Makedonski committed
        ]
    )
    Map JSON_model_json to "JSON" in SOURCE_MAPPING as JSON_SOURCE_MAPPING {
        authors -> "authors",
        books -> "books"
    }
    Map JSON_authors_item to "JSON.authors.item" in SOURCE_MAPPING as JSON_authors_item_SOURCE_MAPPING {
        name -> "name"
    }
    Map JSON_books_item to "JSON.books.item" in SOURCE_MAPPING as JSON_books_item_SOURCE_MAPPING {
        title -> "title",
        authors -> "authors",
        year -> "year"
    }
}