Generate expression file from database query
For some data transformations I would like to use an expression file that is generated each night, instead of querying a SQL database everytime the pipeline is started. I already have data available in the database and now I need to get the data transformed in the expression file JSON format, but I am stuck on getting the right ouput. Coming from a XML oriented environment (with extensive knowledge in XSL but not so much JSON) I have quite some issues with switching to snaps and JSON... Data sample (JSON) from the database [ { "code": "ARTICLEGROUP", "source": "JLG", "target": "10" }, { "code": "COMMODITYCODE", "source": "31251501", "target": "0" }, { "code": "COUNTRYCODE", "source": "AF", "target": "AF" }, { "code": "COUNTRYCODE", "source": "AL", "target": "AL" }, { "code": "COUNTRYCODE", "source": "DZ", "target": "DZ" }, { "code": "COUNTRYCODE", "source": "AS", "target": "AS" }, { "code": "COUNTRYCODE", "source": "AD", "target": "AD" }, { "code": "COUNTRY_ISOCODE", "source": "ARE", "target": "AE" }, { "code": "COUNTRY_ISOCODE", "source": "AFG", "target": "AF" }, { "code": "COUNTRY_ISOCODE", "source": "ALA", "target": "AX" }, { "code": "COUNTRY_ISOCODE", "source": "ALB", "target": "AL" }, { "code": "UOM", "source": "EA", "target": "pi" }, { "code": "UOM", "source": "M", "target": "me" }, { "code": "UOM", "source": "BG", "target": "za" } ] Desired output { "ARTICLEGROUP" : { "JLG": "10" }, "COMMODITYCODE" : { "31251501": "0" }, "COUNTRYCODE" : { "AF": "AF", "AL": "AL", "DZ": "DZ", "AS": "AS", "AD": "AD" }, "COUNTRY_ISOCODE" : { "ARE": "AE", "AFG": "AF", "ALA": "AX", "ALB": "AL" }, "UOM" : { "EA": "pi", "M": "me", "BG": "za" } , getValue : (type, source) => this[type][source] } Anyone can point me in the right direction? Have tried multiple things already, but I can't get the "arrays" right for some reason.33Views0likes3CommentsFlatten JSON files into CSV files
Created by @schelluri The pipeline pattern flattens a JSON file, which has multiple objects, and turns it into a CSV file. Configuration Sources: JSON Generator Targets: CSV file Snaps used: JSON Generator, JSON Formatter, JSON Parser, Script, CSV Formatter, File Writer Downloads MS_Flatten_Script.slp (31.4 KB)7.4KViews1like2CommentsJSON Object Diff
Is there a way to easily show what key values do not match between two JSON objects? If I have two objects with the same keys, can I output just the keys and values that do not match between the two objects? I am looking for a way to do this without having to create an equality expression for each key.7.3KViews0likes10CommentsJson conversion to new object
Hi All, Good morning, I have a requirement for converting json into xml with attributes. So, I understood in order to make the XML with attributes from json, I have to have below structure of json to be feed to xml formatter for final conversion. Required JSON format, [ “h1”: { “h2”:{ “f”:[ {“@name”:“Field1”,“$”:“10/3930”}, {“@name”:“Field2”,“$”:“true”} ] } } ] My Original json is like this [ { “Field1”:“10/3930” “Field2”:“true” } ] How to convert original json to required json structure for XML formatter. Any help will be much appreicated. Regards, San3.8KViews0likes3CommentsHelp with adding a field in JSON output
I have a JSON output like this: { "Choices": { "1": { "Display":"Generating standard, automated reports (e.g. ERP, reporting tools)?" } "2": { "Display":"Generating non-standard / custom reports (e.g. spreadsheets)?" } "3": { "Display":"Responding to Ad Hoc data requests?" } "4": { "Display":"Reconciling, combining, or manipulating data across multiple systems, reports, tools, and excel sheets?" } "5": { "Display":"Analyzing data and building insights?" } "6": { "Display":"Other" } } "QuestionText_Unsafe": "Tools and Reporting</br></br>On an average, what percentage of your time in a given week is spent:" "DisplayDataExportTag": null "DisplayLogic": null} This is one of the result and have multiple like this. So here I have this Field “Choices” where I have these values in numbers then another Child Field “Display” Now I want antoher field with Display which will be TextEntry: “true” but only for the last one or the max one. So for eg: here in choices the last/max field is 6: "6": { "Display":"Other" } It should be like this: "6": { "Display":"Other", "TextEntry":"true" } How do I do that? I’m new to the language.Solved2.7KViews0likes2CommentsJSON snap not working as expected
JSON splitter last week was working correctly. Pipeline was not edited, JSON format did not change, and yet Pipeline is crashing indicating error that JSON splitter is expecting list not an object. Before 17th of Feb it was working perfectly fine. was something changed in snap architecture? “Failure: Json Splitter expects a list, Reason: Found an object of type class java.util.LinkedHashMap, Resolution: The path $.data needs to refer to a list in the incoming document”Solved10KViews0likes16CommentsIngesting multiple AWS S3 files into a database
I have a Amazon S3 bucket containing multiple files that I’d like to extract and read into a database. The files are all .GZ (gzip) files. The file names will change each day but will all have the same format/contents once unzipped. I was thinking it would be like: S3 browser → mapping → S3 reader → JSON Parser → database target But this fails validation at JSON parser step, with: Failure: Cannot parse JSON data, Reason: Unable to create json parser for the given input stream, Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens After the S3 Reader step, I can preview the data and see the list of files that would be imported, but not the contents of the files themselves. Any suggestions for the right way to read in the contents of several files in a S3 bucket at once? Thank you!Solved4.2KViews0likes4CommentsMap Json Structure
Currently we have json data like this : { “Test”: “1” “SerialNumbers”: { “SerialNo”: [ “123”, “456” ] } The desired output is like this: { “Test”: “1” “SerialNumbers”: [ {“SerialNo”: “123”}, {“SerialNo”: “456”} ] } Is there any function we could use to achive this in SnapLogic ?Solved