Git Product home page Git Product logo

Comments (2)

thomasborgen avatar thomasborgen commented on July 18, 2024

About getting key values:

I think the only case where it would make sense to get the keys are when an object of objects work is basically working like a list like the JSONSchema example above or like this:

{
    "people_by_id": {
        "1": {"name": "John", "age": 21},
        "2": {"name": "Bob", "age": 21},
        "3": {"name": "Roger", "age": 21}
    }
}

If we have a structure like this, then more likely than not we want that id number, but we do not want to absolute paths to all objects, we want to iterate over people_by_id.

To get something like that to work we need to figure out a way to represent that in a python dict, because that is what we are using internally, then we would also need to decide on a how it should be looked up in a DataFetcher.

Currently, our iterators makes an object with the given alias available to the DataFetcher. I think we would need to do something similar, but also inject the key name into the aliased object. like this:

{
    "people_item": {
        "__key__": "1",
        "name": "John",
        "age": "21"
    }
}

That way, the only difference internally between an iterated object and an iterated list of object would be that the former have the __key__ key with the original objects key as a value.

from kaiba.

thomasborgen avatar thomasborgen commented on July 18, 2024

About dynamically writing key names

Lets say that we needed to create that JSONSchema from the following csv:

name;type
firstname;string
lastname;string
age;int

There are 2 problems.
First is that when we create a kaiba config we create an object and give it an iterator. What will be produced from that will always be a list. But we don't want a list we want to iterate over some data and produce objects.

Second problem is that we need to be able to dynamically name these objects.

I think that these are two seperate tasks.
To be able to dynamically name an attribute or object we can reuse DataFetcher, but probably give it a spesial name like name_fetcher. This means that we might need to make "name" an object with a default value and a fetched value. (things are getting a bit complicated)

To be able to iterate over some data and produce a list I think we might want to split the kaiba configs "object" into two separate things. One called "list" and one called "object". That way, adding an iterator to an object will always just create an object with named object children. And a list will be create a list of unnamed objects. The "object" config could keep its iterator, but possibly have a spesific datafetcher to name children, which could be something like "path": ["item", "__key__"] when iterating over object with named objects or `"path": ["item", "name"] when iterating normally over another list.

I will start working on some more specific proposals, but these are my initial ideas.

Please let me know how you feel about it @ChameleonTartu I think with this you'd be able to map to and from JsonSchema format in #157

from kaiba.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.