I would like to be able to add and remove objects in an object

{
        "active": true,
        "name": "conjug",
        "description": "Help to conjug words together",
        "type": "API",
        "config": {
            "protocol": "https",
            "host": "nr-faibrik-testsqddqsdqsdmix.net",
            "generic": true,
            "action": {
                "default": {
                    "method": "POST",
                    "path": "/conjug",
                    "mapping": {
                        "in": {
                            "parameters.selector": "selector",
                            "parameters.word": "word",
                            "header.language": "language"
                        },
                        "out": {
                            "response": "response:"
                        }
                    }
                },
                "conjugTwoWords": {
                    "method": "POST",
                    "path": "/conjug/twoWords",
                    "mapping": {
                        "in": {
                            "parameters.word1": "word_one",
                            "parameters.word2": "word_two",
                            "header.language": "language"
                        },
                        "out": {
                            "response": "result"
                        }
                    }
                },
                "getGender": {
                    "method": "POST",
                    "path": "/gender",
                    "mapping": {
                        "in": {
                            "parameters.word": "word",
                            "header.language": "language"
                        },
                        "out": {
                            "response": "gender.result[0]"
                        }
                    }
                }
            }
        }
    }

Hi @abdel74100, can you describe what your exact problem is, what you tried and what did not work?

Hi Stéphane

Thank you for you suport! :sweat_smile:
let me describe my problem to you.

If you see the above data (API configuration data)
we first have generic values:

“active”: true,
“name”: “conjug”,
“description”: “Helps conjugate words together”,
“type”: “API”,

so
2.A nested object name ** config **
in this config object we also have generic values

“protocol”: “https”,
“host”: “nr-faabrik-testsqddqsdqsdmix.net”,
“generic”: true,

after that

3 “action” objects but we could have 1 or 2 or 4 depending on the name of the API here (conjug)

I would like to be able to display all of this and dynamically add or remove actions / mapping / In and mapping / Out and also be able to modify their values.

What is the best solution ?
1.I have thought of a recursive function? for each key whose value is an object I generate an array
2. try to generate the schema dynamically

Hi @abdel74100, I would like to recommend creating a JSON Schema which describes your data format. This JSON Schema can then be handed over to JSON Forms which in turn will render a UI for your data.

I can recommend this guide to get started with JSON Schema.

Hy stephane

I’m already using jsonfom my question is if I should set everything for a schema like mine where there are multiple nested objects it’s long very long or is there a way to do it I’m looking in the documentation…but not found

We have a very basic Generate.schema utility by which you can generate a default JSON Schema based on your data. However the resulting schema will be very basic as it doesn’t know anything about your domain. You could use that as a starting point.

ok thanks i will try and another question jsonform does not support DOT in the key? example: “parameters.selector” is my key and does not appear

Very thanks Stephane

Hi! Dot in keys currently don’t properly work in JSON Forms. We have an open issue for that.

1 Like

Hey Stephane

I would like to generate the schema dynamically according to the datas I give it I use the “json-s-generator” package before switching to jsonform but doesn’t jsonfor already have a way to do it?

thanks

We have a Generate utility we export from @jsonforms/core. With it you can generate JSON Schemas and UI Schemas, e.g. const generatedUiSchema = Generate.uiSchema(schema).

great thank you very much Stéphane !! and how can i access the preprocessing function in the options?
example const generateSchema = Generate.jsonSchema (obj, options);

normally the options have a function to process the input data, don’t they?
for example if i have a type : null i replace it by a type 'string"

We don’t have a preprocessing option. I would like to suggest to preprocess your data/schema/uischema before handing it over to JSON Forms.