a way to convert json files into jsonnet files? - json

is there a way to convert json files into jsonnet files?
I am working on grafana dashboards as code and need to convert a json file into jsonnet. Or is there a good guide on how to create panels in Grfana except the official Jsonnet website? I would be glad if I recieved any help from you!

JSON files are "technically" jsonnet files already, you can prettify them to look like jsonnet with:
jsonnetfmt file.json > file.jsonnet
Of course, the above is just syntax-sugar'izing the original JSON file.
If you want to build Grafana dashboards in a programmatic way, grafonnet-lib would be the way to go

Related

How to create a BQ-schema from XSD

I need some guidance on how to proceed with a problem.
Our integration team receives xml files which are converted to json and sent to pub/sub. We then ingest the json files (or are supposed to) into bigquery.
The problem is that the xml files do not include all possible objects or values all the time. So, I cant create a correct schema in bq to receive the json files. I got the xsd file with an extension file which gives me all possible objects but I don't know how to convert this to a correct bq schema.
Do you have any suggestions on how to create a bq schema from xsd files? I was thinking that if I create an xml file with dummy data (including all objects and more than one object when creating repeated objects) with help of the xsd maybe that xml file may be converted to json and then use the auto-schema detection of bq.
Any suggestions?
Thanks,
Cris
If you have the XSD schema files, you can convert these to a valid JSON schema. There are a few tools that can help you to accomplish this.
Keep in mind that the tools are for general purposes and not for the particular case of BigQuery, so you'll have to tune the result to get a valid JSON schema. For this check the components of a BigQuery schema, and for quick reference the sample provided in the documentation.

LogParser JSON log files

Does LogParser support JSON log files? I am working with an app that outputs simple JSON log files into a folder and I'm trying to run aggregate SQL style queries against the files in the folder.
The format of the files is simple:
{"f1":"value", "f2":NumericValue, "f3":"DateValue", etc...}
You can try out Musoq which already has a plugin that lets you treat json as queryable source.
Unfortunately not. LogParser was written when XML was the cool thing :-)
But you can always write your COM extension and LogParser will be able to query JSON files as well.

How to convert STL file in JSON using Python

I need to convert stl file json using python, is there any way to do this using python programming
Here's a project that will help you to convert .stl files to JSON.
Project GitHub
Also, here's a python module called numpy-stl. It offers a wide range of functionalities for directly working on .stl files.

MarkLogic Java API batch upload files (.csv)

Im trying out the MarkLogic Java API and would want to bulk upload some files with the extension .csv
I'm not sure what to use, since the Java API only supports JSON, XML, and TXT files.
How do I batch upload files using the MarkLogic Java api? Do i convert everything to JSON?
Do i convert everything to JSON?
Yes, that is a common way to do it.
If you would like additional examples of how you can wrangle CSV with the Java Client API, check out OpenCSVBatcherExample and JacksonDatabindTest.testDatabindingThirdPartyPojoWithMixinAnnotations. The first demonstrates converting the csv to XML and using a custom REST extension. The second example (well, unit test...) demonstrates converting the csv to JSON and using the batch upload (Bulk Writes) capabilities Justin linked to.
If you have CSV files on your filesystem, I’d start with mlcp, as suggested above. It will handle all of the parsing and splitting into multiple transactions/batches for you. Take a look at the mlcp documentation for more details and some example configurations.
If you’d like more control over the parsing and splitting logic than mlcp gives you out-of-the-box or you’re getting CSV from some other source (i.e. not files on the filesystem), you can use the Java Client API. The Java Client API allows you to efficiently write batches using a WriteSet. Take a look at the “Bulk Writes” example.
According to your reply to Justin, you cannot use MLCP because it is command line and you need to integrate it into a web portal.
Well, MLCP is released as open cource software under the Apache2 licence. So if you are happy with this licence, then you have the source to integrate.
But what I see as your main problem statement is more specific:
How can I create miltiple XML OR JSON documents from a CSV file [allowing the use of the java API to then upload them as documents in MarkLogic]
With that specific problem statement:
1) have a look at SplitDelimitedTextReader.java from the mlcp source
2) try some java libraries for this purpose such as http://jsefa.sourceforge.net/quick-tutorial.html

Convert Swagger JSON to RAML/YAML

How do I convert Swagger JSON to RAML/YAML and validate it? I am not looking for a programmatic way, just a one off conversion.
Here are the steps:
Export Swagger JSON into a file on your drive. This JSON should be published on your server at the following URI: /swagger/docs/v1
Go to http://editor.swagger.io/#/
On the top left corner, select File-> Import File... Point to the local Swagger JSON file you exported in step #1 to open in the Swagger Editor
Select Generate Client -> Swagger YAML option from the menu
It will generate the YAML that you can validate at http://www.yamllint.com/ site
To convert API spec between various formats (e.g. Swagger/OpenAPI, RAML, Postman, etc), you can use the following free and open source tools:
https://github.com/lucybot/api-spec-converter
https://github.com/stoplightio/api-spec-converter
Its actually pretty simple
Web version of swagger editor gives the flexibility to import your existing swagger file(JSON/YAML) and download the configuration file that is currently being shown. So just combine these two.
Note: Converting JSON to YAML exists, but not JSON to RAML
First import your swagger JSON at http://editor.swagger.io/#/ (File > Import File)
Once you see your configurations, just download the corresponding YAML version (File > Download YAML).
The YAML version of the JSON you just uploaded will be downloaded.
Conversion
If you are looking to convert from any version Swagger to RAML 0.8 then APITransformer.com can do it for you. We're almost done with RAML 1.0 export. Will release it in a week's time.
Validation
The converted description comes out of the same code-gen engine that APIMatic uses to validate an API description before generating SDKs/Client libraries. Therefore, the converted RAML will be validated by default.
API descriptions in a variety of formats can also be validated via APIMatic's CLI or APIMatic's API
While I wish there was a command line tool, this company has made a converter it seems:
https://apitransformer.com/