Conversion from XML to Json removes 0 in Azure Data Factory - azure-data-factory

I am converting XML files to Json(gzip compression) using Azure Data Factory.
However , I observe that in the XML file I have the values stored as 0123456789. However , when this is converted to Json it is saved as "value" : 123456789. Without 0.
I would like to keep the Json values as-is from the XML . Please provide suggestions for the same.

I recently found using data flow will solve the problem.
I created a simple test. My xml file is as follows:
<?xml version="1.0"?>
<note>
<to>George</to>
<from>John</from>
<heading>Reminder</heading>
<body>Don't forget the meeting!</body>
<number>0123456789</number>
</note>
Set the xml file as the source data. Please don't import Projection.
By default, all columns will be treated as string types.
The data preview is as follows:
Set the json file as the sink:
Select Output to single file and specify the file name.
The debug result is as follows:
That's all.

I've found that you can change the projection mapping using the "Script Editor"
So you can keep your "projection" by importing, during a debug session, the sample you are using.
Once your projection is done you can edit the "Script" to change the type of your tag
Select the Script Editor button
You should have a script that look like that :
source(output(
note as (to as string, from as string, heading as string, body as string, number as integer)
),
allowSchemaDrift: true,
validateSchema: false,
limit: 100,
ignoreNoFilesFound: false,
rowUrlColumn: 'fileName',
validationMode: 'none',
namespaces: true) ~> XmlFiles
You can change the type of your tag "number" to string type
source(output(
note as (to as string, from as string, heading as string, body as string, number as string)
),
allowSchemaDrift: true,
validateSchema: false,
limit: 100,
ignoreNoFilesFound: false,
rowUrlColumn: 'fileName',
validationMode: 'none',
namespaces: true) ~> XmlFiles

Related

How to define a header parameter with multiple attributes in OpenAPI 3.0?

I need to define a header parameter like this X-Custom: id1=uuid1;id2=uuid3
Since this is a common header for all paths I want to define it once and reference it every time. So far I came up with this:
openapi: 3.0.3
components:
parameters:
customHeader:
name: "X-Custom"
in: header # <--- produces error
required: true
schema:
type: object
properties:
id1:
type: string
format: uuid
id2:
type: string
format: uuid
style: matrix
explode: true
But I get an error that 'header' is not allowed and the parameter does not show up in the preview.
Any idea what's wrong?
OpenAPI 3 supports only style: simple for header parameters. This means that objects can be serialized in one of two ways:
# {"id1": "uuid1", "id2": "uuid2"} becomes...
# explode: false
X-Custom: id1,uuid1,id2,uuid2
# explode: true
X-Custom: id1=uuid1,id2=uuid2
Note that none of these styles match your expected format X-Custom: id1=uuid1;id2=uuid2 with ; as a separator. In fact, OpenAPI currently does not have a way to define ;-separated header values.
The most you can do is define the entire header as a string, mention the header value format in the description, and provide an example value:
customHeader:
name: X-Custom
in: header
required: true
schema:
type: string
example: id1=uuid1;id2=uuid2
There are existing feature requests to improve header serialization styles in OpenAPI:
Support for structured-headers de/serialization
Make it easier to define link headers
If you are designing a new API rather than documenting an existing one, another workaround is to split the header into two headers:
X-id1: uuid1
X-id2: uuid2

How do I express JSON-API sparse fieldsets with OpenAPI-3.0

I'm implementing an OpenAPI-3.0 spec for my API, and I plan on using sparse fieldsets as a parameter for GETs. The examples for parameters using style=deepObject are a little sparse, so I'm not sure if I've got this exactly right.
- in: query
name: fields
style: deepObject
schema:
type: object
additionalProperties:
type: string
Can I combine both the deepObject and additionalProperties options?
I want to support flexible query parameter inputs like this:
GET /articles?include=author&fields[articles]=title,body&fields[people]=name
but I don't want to have to spell out every single option for each resource and field.
Your definition is correct. You might also need to add allowReserved: true so that the comma in =title,body is not percent-encoded, and you can add a parameter example value for documentation purposes:
- in: query
name: fields
style: deepObject
allowReserved: true
schema:
type: object
additionalProperties:
type: string
example:
articles: title,body
people: name
When using "try it out" in Swagger UI, enter the parameter value in the JSON format like so:
{
"articles": "title,body",
"people": "name"
}
Swagger UI will serialize the parameter as
?fields[articles]=title,body&fields[people]=name

Override Schema defined in Telescope(Meteor)

I am currently customizing Telescope heavily, which is written in Meteor.
I need to go over the 3,000 character defined in Telescope's Posts schema's body defined here in the source.
I've been able to customize the HTML and JS, but not the models. How would I do so?
Just create a file under your lib folder and use the documentation here: http://docs.telescopeapp.org/docs/custom-fields to remove or add fields to that Schema.
EDIT: Sorry, but reading carefully your comment I understood you want to modify the autoForm props rather than the Schema itself. To change the maximum allowed value, do something along these lines:
Posts.removeField("body");
Posts.addField({
fieldName: 'body',
fieldSchema: {
type: String,
optional: true,
max: 5000,
editableBy: ["member", "admin"],
autoform: {
placeholder: 'Cannot exceed the maximum length of 5000 characters',
row: 10,
type: 'textarea'
}
}
});

Meteor - Update Collection with location object (in GeoJSON format)

Here is my schema (simple schema):
officelocation: {
type: String,
label: 'Location of Office',
autoform: {
type: 'map',
afFieldInput: {
type: 'map',
geolocation: true,
searchBox: true,
autolocate: true
}
}
},
location: {
optional: true,
type: 'Point'
}
My server side js code is below (note this is in a collection.after hook) so I want to update it based on the address that user has entered, which I have resolved into lat long:
Providers.update({_id: doc._id}, {$set: {location: {type:"Point", coordinates:[lng,lat]} } });
When I see the file in the collection (db.providers.find();), I see the below.. Note that the location embedded object is empty:
{ "_id" : "X8ZfKYJAP9cduwvmd", "phone" : 999999999, "officelocation" : "40.7192714,14.872363899999982", "createdAt" : ISODate("2015-04-24T02:00:40.447Z"), "updatedAt" : ISODate("2015-04-24T02:00:40.799Z"), "owner" : "GB4TxTHodkykeeXp6", "officeaddress" : "Via Califri, 5, 84099 San Cipriano Picentino SA, Italy", "location" : { } }
I am basically trying to make sure by collections are stored in a geo-spatial-searchable way, but this approach does not seem to work. Any help?
There could be a number of things causing your update to fail, from allow-deny rules to Simple Schema cleaning out your data.
I see that you are using a custom type to store your location. Make sure you have used a Transform to ensure the type isn't lost on the way to the server. From the Simple Schema readme:
Custom object types are treated as blackbox objects by default. However, when using collection2, you must ensure that the custom type is not lost between client and server. This can be done with a transform function that converts the generic Object to the custom object. Without this transformation, client-side inserts and updates might succeed on the client but then fail on the server. Alternatively, if you don't care about losing the custom type, you can explicitly set blackbox: true for a custom object type instead of using a transformation.
Alternatively you could use a sub-schema to define what a location is allowed to look like, instead of using a custom type, but it won't keep the methods of the Point type.

CreateObject with values from JsonFile

I have some Objects Constructor eg:
AM(power: String, speed: String, Height: String, position: PlayerPosition)
Constructor2(motivation: String, description: String, age: Int)
Then I have a JsonFile that holds data needed for all constructors
Is there a way or some library that allows me to parse the contents of the file in a way that allows me to use it for constructing the objets:
eg:
AM(jsonParser.power, jsonParser.speed,jsonParser.Height, jsonParser.position)
I have multiple JsonFiles and the contents are not always the same structure so I was hoping I could use a parser and have access to the data like key: Value pair.
I am quite new to Scala, I know in ruby there are ways that this can be easily achieved and I was hoping this can be done quite easily
So if my file was a json like:
{
"power": "25"
"speed": "65"
"description": "hello"
}
I would be able to data = jsonParse(jsonFile)
then data.speed would equal "25"
I would introduce an intermediate format, that transforms the JSON to a specific case class and map then to the required format.
Every solution depends a bit on the library you use.
I could add an example for play-json if you use this library.