1493
Views
18
Comments
Solved
Quick way of creating Structure

Hi,

I'm have a list of column names (let's say there are more than 200) and I want to create a Structure for it. There isn't any Entity with the same columns so I can't copy and paste them to my Structure.

I see that there is an "Add structure from JSON" option. And I've tried to use it, but I don't fully understand it. I tried to look for documentation about how to use it, but there is none. How do I add other information for my Structure Attributes like Description, Label, Data Type, Length...? Is that possible to do with this JSON option? Because I can only make a Structure Attribute with basic info like Name.

If it's not possible with this JSON option, what is the fastest way for me to create Structure with lots of Structure Attributes in OSP?

Thanks

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Solution

Hi Loi,

OutSystems guesses the data type from the JSON. So if the JSON value is "string" it's Text, if it's 0 it's Long Integer, if it's 0.0 it's Decimal, if it's true it's Boolean, if it's 2019-04-17 it's Date, and if it's 2019-04-17T08:40Z it's DateTime.

Other Properties, like length, need to be set manually.

2018-11-05 02-29-37
Jay Santos

Hello Loi,

Do you mind sending an example of your JSON file?

I tried with the following

{"menu": {
  "id": "file",
  "value": "File",
  "popup": {
    "menuitem": [
      {"value": "New", "onclick": "CreateNewDoc()"},
      {"value": "Open", "onclick": "OpenDoc()"},
      {"value": "Close", "onclick": "CloseDoc()"}
    ]
  }
}}


And all the structures were created

2017-07-24 06-43-32
Erik Brzozowski

If you have an XML you can convert this XML to json using a online tool and then import the json

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Loi,

There's no way to do what you want except manually. Note that in general, having Structures with so many Attributes points to design errors...

UserImage.jpg
Loi Hua

@Jay Santos

Actually I just want a simple Structure with lots of Attributes on it.

Example:

{ 
 "id": "file",
 "value1": "file",
 "value2": "file",
 "value3": "file",
 "value4": "file",
}

Btw, how can I set the Data Type for each of the Attribute?
I tried your code and "file" made the Attribute Data Type "Text", how can I change it to "Integer", "Decimal". etc...
Is there a documentation anywhere, because I couldn't find it. Thanks!

@Erik

Sr, I don't have the XML for it. What I tried is that I turn all the column names into csv, then converted them to json and import them. So far so good. But what I want to know is how to set other properties of Structure Attribute without having to input them manually on the Platforms, because that will be the quickest way of create Structure I found.

@Kilian

I see, so what I can only do is like I said above to quickly generate Structure with lots of Attributes. For other properties, I have to manually input them. I just hope there is other way than that. And more documentation on how to use the Platform.

@Everyone

So other than JSON, is there any other way I can create Structure quickly?

Thanks

2019-01-04 10-45-45
Sravan Vanteru

Hi Loi Hua,

I don't think we have any other option than manual creation and JSON.


Sravan 

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Solution

Hi Loi,

OutSystems guesses the data type from the JSON. So if the JSON value is "string" it's Text, if it's 0 it's Long Integer, if it's 0.0 it's Decimal, if it's true it's Boolean, if it's 2019-04-17 it's Date, and if it's 2019-04-17T08:40Z it's DateTime.

Other Properties, like length, need to be set manually.

UserImage.jpg
Loi Hua

@Sravan
Well, thank you for your info :) Guess I'll have to try and find my own way.

@Kilian
I tried to what you suggest, and some of it worked like Text, Long Integer, Decimal and Boolean. Other like Date, Time, DateTime and Integer, I have no luck.
Can you share your sample JSON? Here's what I tried.


2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Loi,

You need to add quotes around the date and date time literals, I forgot to add them in my previous post. I have no luck auto-creating a Time Attribute, "00:00:00" just stays Text. Any integer value will create a Long Integer, it's not possible to auto-create Integers.

2014-10-21 20-15-17
Alberto Ferreira

Only to add

For Time type, it works

"Time"    : "12:10:05",

What I could not achieved is to get DateTime

2014-10-21 20-15-17
Alberto Ferreira

Ok I get it! 


if I used 

"DateTime": "2019-02-15T12:10:05",


I get DateTime format, as Kilian has said


2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Oh my... it seems "Time" only works with hours <=12 :)

2014-10-21 20-15-17
Alberto Ferreira

That's it!! I think must be reported to OutSystems

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Already did :)

UserImage.jpg
Loi Hua

Hey guys, thanks for all the answers.

I'll just do what I can for now!

2025-12-04 09-01-03
Kiet Phan
Champion

@Kilian Hekhuis 

Hello, i have a question.

how should my Json be for outsystems to recognize the Binary Data.

thank you!!


2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Binary Data in JSON doesn't exists as such, it's Base64-encoded text. So when consuming a REST method, or creating a structure from JSON, with binary data, you'll get a Text attribute. You need to manually set it to Binary after the REST method is consumed / the structure is created from JSON.

2025-12-04 09-01-03
Kiet Phan
Champion
2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.