DataWeave is a functional language designed by MuleSoft for transforming data structures defined in for example JSON, XML or CSV. You'll notice that the reduce function has the signature (':array', ':function') => ':any'. Gartner names MuleSoft a Leader and a Visionary, Unleash the power of Salesforce Customer 360 through integration, Integrate Salesforce Customer 360 to digitally transform your business, Get hands-on experience using Anypoint Platform with a free online course, Watch all your favorite on-demand sessions from CONNECT, including the keynote address, Manage and secure any API, built and deployed anywhere, Connect any system, data, or API to integrate at scale, Automate processes and tasks for every team, Power connected experiences with Salesforce integration, Get the most out of AWS with integration and APIs, Connecting your first SaaS application to Salesforce, How to set up your global elements and properties files in Anypoint Studio, How to secure properties before deployment in Anypoint Studio, How to set up API Autodiscovery in Anypoint Studio, How to apply Client ID enforcement policy to your Mule app in API Manager, Best practices to design your first API Specification, Build your first API Specification with API Designer, How to use MuleSofts Anypoint Platform APIs to manage API Specifications, Explore the Anypoint Platform APIs with the Postman Collection, How to implement a Custom Policy in API Manager: Circuit Breaker Policy, What is DataWeave? We cant pass an Object to a for-each scope, and we dont need to label the groups by orderId because each item in the group already contains the orderId. rev2023.3.1.43266. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. Look no further! For example, you might want to render the object values, so you can . Transform an object of references into an array of references in the reponse for Get Task Details action. Is there a colloquial word/expression for a push that helps you to start to do something? Can a VGA monitor be connected to parallel port? Copyright 2023 Salesforce, Inc. All rights reserved. What is object concatenation and how to use it in Mule 4 - DataWeave (DW) 2.0. { ()}. . We can solve this problem by converting the Object to String | Binary, and in order to achieve that we can use DataWeave function write (). This course is for developers interested in advancing their DataWeave 2.0 skills beyond those taught in the Fundamentals course. Learn more about it in the official docs. upgrading to decora light switches- why left switch has white and black wire backstabbed? The first step is to group the data into their own orders (grouped by orderId). pluck is similar to other Object-like functions, for example, filterObject or mapObject. Copyright 2023 Salesforce, Inc. All rights reserved. As we can see, the variable list4 has an extra field, 'province', which is not present in the variable list3. DataWeave in Mule 3 apps, refer to Joins two array of objects by a given ID criteria. This book attempts to cover important concepts for mastering the language that are not currently covered by the MuleSoft documentation. But here you can find an example that transforms the input Object into an output Array using all three parameters from the lambda. MacroOutput (astype Object) NewDates (astype DateTime ()) NewDates = convert.ChangeType (MacroOutput,NewDates.GetType) Another option: I can see the MacroOutput array in the locals window during execution and it has the proper dates I need to work with, so I know it is valid. We would like to thank MuleSoft Ambassador Joshua Erney for their contribution to this developer tutorial. Next, specify a property name for each child object's key, and a new property name for the properties within each child object. Since were only using value in the pluck call from the last line, you can also use the dollar-sign syntax to make the code simpler. Opinions expressed by DZone contributors are their own. You need to surround the env.name field in parentheses to correctly reference the value of the environment name when using it as a Key. We could accumulate into a collection like an Array if we wanted, or even an Object. Over 2 million developers have joined DZone. In this tutorials, we will be looking into three techniques which objects can be changed in to array using any of these three methods: Object.keys(), Object.values(), and Object.entries() Say we have a cart object defined as follow: Convert an Array to an Object. Deserialize by var model = JsonConvert.DeserializeObject<RootObject> (json); using NewtonJson. At Variants map, after the "->" is using curly bracket {} to output array elements. Let's take a step back and look at all of our examples. element meets the condition. Why are non-Western countries siding with China in the UN? pluck is similar to other Object-like functions, for example, filterObject or mapObject. var v = Object.values (superHeroes); Here, we have defined variable named superHeroes with the object values as shown above. Is quantile regression a maximum likelihood method? Input Parameters. This is where we use pluck after we already grouped the list by orderId. DataWeave gives us the pluck function to achieve this. In this case, we want an Array of Arrays, where each internal Array contains the individual line items for a particular order. from <= indexOf(array) < until. What is the ideal amount of fat and carbs one should ingest for building muscle? You can try all of these examples with the DataWeave Playground. $ represents the item (n), while $$ represents the accumulator (total). Go to json2csharp.com. You will also learn how to use pluck in combination with groupBy to achieve a common use case. Weapon damage assessment, or What hell have I unleashed? When using the infix notation, you dont have to include all the parameters in the lambda if youre not using them. We first load the data file (stream), convert it to string, then "object to json" converts it Java object. length; i++) byteArray [i] = array [i]; Or the for loop can be replaced with a stream if you want: Over 2 million developers have joined DZone. Learn DataWeave with the Online DataWeave Playground and Interactive Tutorial. Selects the first n elements. The second parameter represents the present value of the accumulator. When it comes to transforming between arrays and objects we have four different permutations: Depending on your experience, you may have picked up that there are a handful of functions that you will typically reach for in these situations. We have the outermost array that we want to compress into an object, and within each object in the outermost array, there is another array we need to compress into an object. This DataWeave example uses the DataWeave map function to iterate through the object elements that match the key book. If we need to access individual groups and deal with each line individually this is the shape of data we want. [NEW] DZone's 2023 "DevOps: CI/CD, Application Delivery, and Release Orchestration" Trend Report, https://docs.mulesoft.com/mule-runtime/4.3/dw-core-functions-pluck, https://docs.mulesoft.com/mule-runtime/4.3/dw-core-functions-reduce, Dev vs. Ops: Conflicted? What function do you reach for? $ represents the first argument: the value from the key/value pair (value), $$ represents the second argument: the key from the key/value pair (key), and $$$ represents the third argument: the index for each key/value pair (index). Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. Step 1: Using nested map to 1st outer loop at Orders, then 2nd inner loop at Items, finally 3rd inner loop at Variants. By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. How to Append the object into array in mule4 INPUT: [ { "message": "Hello world!" }] DataWave: %dw 2.0 output application/json --- payload ++ {prepay: "Y", prepayRate: "ratePerLine"} DataWeave 2 Upvote 4 answers 4K views Log In to Answer Subscribe to thread Don't see what you're looking for? The type returned from the lambda (R) is the same type that is returned from the reduce call. You also learned how to use pluck in combination with groupBy to achieve a common use case. The module dw::core::Arrays has extra functions that are useful when working with arrays in DataWeave. To learn more about it, check out this tutorial. Transforming Complex XML Data Structures The XML data structure doesn't support arrays. Sometimes we get a data structure with keys and values and we want to create an array with data from the data structure. How to convert Array of Object to Object in DataWeave 2.0 I have an array: [ { "number": 11111111, "type": "Phone" }, { "number": 222222222, "type": "Mobile Phone" } ] to {"Phone":11111111, "Mobile Phone": 222222222} DataWeave 2 Upvote Answer Share 7 answers 12.04K views Top Rated Answers All Answers Log In to Answer Subscribe to thread You can check out these other tutorials if you feel a bit lost with some concepts: The reduce function takes two parameters: an Array and a lambda. However, those two will return an Object, as opposed to pluck that returns an Array. Add a Transform Message (DataWeave) Component Define input and output metadata using above JSON and XML files as examples. You can use the dollar-sign syntax to reference the three arguments that are passed to the lambda (i.e., value, key, and index). This is how we can transform the array data structure in DataWeave 2.0 (Mule 4). You can also use conditional statements like if/else or match/case to transform the data into a different type. Returns true if every element in the array matches the condition. You dont always need to assign an initial value to the accumulator in the lambda (total=0). The Dataweave 2 examples below describe how to convert between Objects and Arrays. If we want to see the items which are present in array 1 but not in array 2, we can use the "--" function. In the following examples we have object structure with keys book1 and book2 that we want to transform to an array. Our reduce checks if the count field is true and adds the value into the accumulator (acc). What are examples of software that may be seriously affected by a time jump? You didn't specify how firstname and lastname are transformed. If you come from a different development background, this is something similar to a while or do while. Previously, converting from an object to an array was the only direction with built-in methods for the Object class. Cant we convert this into array, How to convert object to array in dataweave, The open-source game engine youve been waiting for: Godot (Ep. Heres an example of using pluck to take an Object and create an Array where each element is a single key/value pair from the input Object. At Orders and Items map, note that after the "->", is using parentheses (), this is to output array of array only, without array's elements. In this next example, we transform an input Array into a Number. Convert Json String to C# Object List. As always, feel free to send me a message on LinkedIn if you have any questions. The lambda has three arguments: the value for a key, the key itself and the index of the key in the object. PTIJ Should we be afraid of Artificial Intelligence? In DataWeave 2.0, concatenation can be achieved by using the ++ (plus plus) function. Why do we kill some animals but not others? This module contains helper functions for working with arrays. The Dataweave 2 examples below describe how to convert between Objects and Arrays. Learn about the DataWeave Playground's functions and where to find the interactive tutorial. Anybody dealing with Dataweave scripts will often come across situations where an Object needs to be converted into an Array or vice-versa. Functions Continue your development journey with the rest of the tutorials to become a master in DataWeave. The lambda is called with the current value of the iteration, plus whatever the current value of the accumulator is. You can try all of these examples with the DataWeave Playground. You can use json2csharp.com to Convert your json to object model. Do lobsters form social hierarchies and is the status in hierarchy reflected by serotonin levels? Asking for help, clarification, or responding to other answers. The job of the lambda is to return a new accumulator for each iteration. Was attempting something like this: If you dont do this, then the String "k" will be taken instead. A link to my unfinished DataWeave book. While the above scenario can be done easily with the default Dataweave operator, let's dive into the complex situation of comparing dissimilar arrays. Gartner names MuleSoft a Leader and a Visionary, Unleash the power of Salesforce Customer 360 through integration, Integrate Salesforce Customer 360 to digitally transform your business, Get hands-on experience using Anypoint Platform with a free online course, Watch all your favorite on-demand sessions from CONNECT, including the keynote address, Manage and secure any API, built and deployed anywhere, Connect any system, data, or API to integrate at scale, Automate processes and tasks for every team, Power connected experiences with Salesforce integration, Get the most out of AWS with integration and APIs, Connecting your first SaaS application to Salesforce, How to set up your global elements and properties files in Anypoint Studio, How to secure properties before deployment in Anypoint Studio, How to set up API Autodiscovery in Anypoint Studio, How to apply Client ID enforcement policy to your Mule app in API Manager, Best practices to design your first API Specification, Build your first API Specification with API Designer, How to use MuleSofts Anypoint Platform APIs to manage API Specifications, Explore the Anypoint Platform APIs with the Postman Collection, How to implement a Custom Policy in API Manager: Circuit Breaker Policy, What is DataWeave? You will get C# Code for your object model. But here you can find an example to sum all of the numbers in an Array. 542), We've added a "Necessary cookies only" option to the cookie consent popup. Why does the Angel of the Lord say: you have not withheld your son from me in Genesis? The lambda function is defined like this: It takes in two parameters and returns one. The accumulator for reduce could be any type. and the original array when n > sizeOf(array). We use the infix notation of the function so our input object is followed by the pluck function and lambda: In the next example we add an if/else to the lambda: This page is built with In this tutorial, you will learn how to transform an input Object into an Array with the pluck function. Anypoint Platform Development: DataWeave (Mule 4). Ref: https://docs.mulesoft.com/mule-runtime/4.3/dw-core-functions-reduce. This template is available in Power Apps and Power Automate. default -> fn ($) } %function trimWhitespace (v) trim v when v is :string otherwise v. %var object = applyToValues (payload, trimWhitespace) ---. It can be used to transform an Array into any other type. We end up with the total count of the numbers that had count=true. In fact, transforming from an Array to an Object is a very common task for reduce. To use this module, you must import it to your DataWeave code, for example, Asking for help, clarification, or responding to other answers. Making statements based on opinion; back them up with references or personal experience. Does With(NoLock) help with query performance? when it reaches an element that fails to satisfy the condition. To start, specify the path to the parent object or collection and the property subpath within the parent where the array is located. If you recall from my previous blog post on reduce, you can use reduce to transform an array into whatever you want, a single value, a collection of values, a collection of collections, etc. Returns the sum of the values of the elements in an array. To overwrite the existing array, the path would be the previously specified parent path and property subpath. This is the most used notation for this function because it makes it easier to read and understand. Browse other questions tagged, Where developers & technologists share private knowledge with coworkers, Reach developers & technologists worldwide. Array groupBy (Array<T>, ( (T, Number) -> R)): Object< (R), Array<T>> String groupBy (String, ( (String, Number) -> R)): Object< (R), String> Object groupBy (Object< (K), T>, ( (V, K) -> R)): Object< (R), Object< (K), V>> groupBy does not return an Array or any of the given input values. map to go through each object in the array thats returned by the multi-value selector. A reflection on 10 things I'm glad I did with my 20s. 3. In this tutorial, you learned how to transform an input Object into an Array with the pluck function. Did the residents of Aneyoshi survive the 2011 tsunami thanks to the warnings of a stone marker? It is used to accumulate the result as reduce iterates through the input Array. x-ms-apimTemplateParameter.propertyParentPath, x-ms-apimTemplateParameter.propertySubPath. It can be used to transform an Array into any other type. This is iterating over each value of the array, and accumulating the result of {(ordinalize v): v} into an object. If the value is not found, the function returns -1. DataWeave - Transforming an Array to an Object How to transform Arrays into Objects in DataWeave Joshua A Erney Jul 17, 2018 3 min read When it comes to transforming between arrays and objects we have four different permutations: Array -> Array Object -> Object Object -> Array Array -> Object Use new String (byte []) to obtain the base64 string but a base64 decoder . 3.3. Whats the accumulator? Dataweave does not know that JSON is being parsed and will escape the quotations SOLUTION Instruct Dataweave via the read () function to treat the string as JSON. How to convert JSON object to Json Array using dataweave 2.0 sanvyju Edited September 26, 2019 at 7:22 AM How to convert JSON object to Json Array using dataweave 2.0 Hi Folks, i want convert my JSON object to Json array and dynamic nested json object also there but it should be set into be JSON array. Input: You can use the reduce() function to transform an array into an object. After first pass the object, obj, is. If you come from a different development background, this is something similar to a while or do while. What is the best way to deprotonate a methyl group? This function is not commonly used with the prefix notation because of its complexity. Weve effectively grouped all the data into their own orders. specified number of elements. Learn DataWeave with the Online DataWeave Playground and Interactive Tutorial. Gartner names MuleSoft a Leader and a Visionary, Unleash the power of Salesforce Customer 360 through integration, Integrate Salesforce Customer 360 to digitally transform your business, Get hands-on experience using Anypoint Platform with a free online course, Watch all your favorite on-demand sessions from CONNECT, including the keynote address, Manage and secure any API, built and deployed anywhere, Connect any system, data, or API to integrate at scale, Automate processes and tasks for every team, Power connected experiences with Salesforce integration, Get the most out of AWS with integration and APIs. How to transform Arrays into Objects in DataWeave. In this case, below code snippet could help us to compare based on the identical fields between the two arrays: If we want to find the elements in list4 but not in list3. Each element of the array into is transformed into an object (key-value pairs) and then is concatenated in the accumulator so all key-pairs are joined into a single object. Learn about the DataWeave Playground's functions and where to find the interactive tutorial. Before you begin, note that 2.x versions of DataWeave are used by Mule 4 apps. First letter in argument of "\affil" not being output if the first letter is "L". What tool to use for the online analogue of "writing lecture notes on a blackboard"? Is the Dragonborn's Breath Weapon from Fizban's Treasury of Dragons an attack? Thanks for contributing an answer to Stack Overflow! While not required to follow this tutorial, a good understanding of the basic DataWeave concepts would be preferred. Opinions expressed by DZone contributors are their own. We use a lambda to define the mapping from our object to elements in the resulting array. We would like to thank MuleSoft Ambassador Joshua Erney for their contribution to this developer tutorial. After the last iteration, the accumulator is what finally gets returned from reduce. The reduce function is about as close as we get to a general-purpose looping tool in DataWeave. Youll have to use the explicit lambda in order to do that. But things tend to get blurry when you need to transform an array into an object. Finally, specify the path where the new object property will be written to. So then that output value will be set as the value of this variable. Dataweave: Transform Message 1: %dw 2.0 output application/java --- payload.parts.ledger.content Transform Message 2: %dw 2.0 output application/json --- read (payload,"application/json") React can only render primitive types like a string, a number, or a boolean. reduce then moves on to the next iteration, which uses the third and final item in the Array. If you are only interested only in the contents of the array then you can use the DataWeave expression payload.Person which will return ["sri", "123456","India"], which is a valid array in JSON. Learn more about MuleSoft here! React, Angular, and Vue.js: Whats the Technical Difference? and so on, until the array has no more values to iterate over. The input argument is an object and a lambda and the output must be an array. It can be used to perform the task of map, filter, distinctBy, groupBy, and other functions that take in Arrays. It can be used to perform the task of map, filter, distinctBy, groupBy, and other functions that take in Arrays. Is email scraping still a thing for spammers. It might strike you to scroll through the documentation here and see if you can find a function with a signature like (':array', ':function') => ':object' (meaning the function has one input of type :array, another input of type :function, and returns one value of type :object). Splits an array into two at a given position. If no operation is selected, this policy will apply to all operations. we have imported core::Strings from dataweave as we need to String Operations; The three dashes specify that the final result from codes below to it should be the output value from this dataweave expression. List of actions and triggers to which the policy will apply to. that do not. Connect and share knowledge within a single location that is structured and easy to search. You can then use the Array interface and not care what the actual type is. Java - array types to Object type cast. For example, ((n, total) -> total + n). Assign an initial value to the parent where the new object property will be set as the value into accumulator. Care what the actual type is object in the array is located actual is... Interface and not care what the actual type is Power Automate the ideal amount of fat and one. Array contains the individual line items for a push that helps you to start to do something is functional. Support Arrays DataWeave Playground 's functions and where to find the Interactive tutorial individually is. Pluck is similar to other answers L '' we get to a while or do while your JSON object! Object needs to be converted into an output array using all three parameters from the function... Not being output if the value into the accumulator object values as shown.! Subpath within the parent object or collection and the output must be an array into any type... This URL into your RSS reader ( array ) < until collection like an array of references into an to! Like to thank MuleSoft Ambassador Joshua Erney for their contribution to this developer tutorial option to the next,... Thank MuleSoft Ambassador Joshua Erney for their contribution to this developer tutorial, we transform an array we... Pluck after we already grouped the list by orderId what hell have I unleashed returns the sum of the DataWeave. Transforming from an object a push that helps you to start to do that array is.! As shown above start, specify the path convert object to array in dataweave the new object property will be written to in. `` k '' will be written to final convert object to array in dataweave in the lambda shape of data want. Groupby, and Vue.js: Whats the Technical Difference their own orders to go each... Opinion ; back them up with the object values, so you can find an to... On to the warnings of a stone marker we wanted, or even an object returned... Acc ) tool in DataWeave 2.0 ( Mule 4 ) list4 has extra! ++ ( plus plus ) function had count=true then moves on to the next,. Step is to return a new accumulator for each iteration you will also learn how to pluck. Breath weapon from Fizban 's Treasury of Dragons an attack 's Treasury of Dragons an attack a particular order where! Key book logo 2023 Stack Exchange Inc ; user contributions licensed under CC BY-SA object concatenation how! You need to access individual groups and deal with each line individually this is how can... Connect and share knowledge within a single location that is structured and easy to.! Amount of fat and carbs one should ingest for building muscle this tutorial argument is an object needs to converted. To decora light switches- why left switch has white and black wire backstabbed this book to. For get task convert object to array in dataweave action ', which is not found, the function returns -1 previously parent. ( ( n ) moves on to the warnings of a stone marker gives... Given position of DataWeave are used by Mule 4 apps 2.0, concatenation can be to. References into an array of Objects by a given position or even an object,,. Be the previously specified parent path and property subpath let 's take a step back look. And share knowledge within a single location that is structured and easy to search currently covered by the multi-value.! Will return an object is a very common task for reduce item (,! Argument is an object array matches the condition object is a functional language by. Key, the key itself and the index of the environment name when using it a. Acc ) module contains helper functions for working with Arrays in DataWeave 2.0, concatenation can be used transform! Your object model about as close as we can transform the data into their own orders ( grouped by.. But not others collection like an array into an array feed, copy and paste URL. Being output if the first letter in argument of `` \affil '' not being if... Helps you to start to do something connected to parallel port variable list3 Fizban 's Treasury of Dragons attack. Convert between Objects and Arrays how firstname and lastname are transformed whatever the current value the. Letter is `` L '' is available in Power apps and Power Automate fat carbs... Writing lecture notes on a blackboard '' with the object elements that match the in. Your object model lecture notes on a blackboard '' of `` writing lecture notes on a blackboard?... Is structured and easy to search master in DataWeave 2.0 ( Mule 4 apps achieve a common case... Existing array, the key book in DataWeave groups and deal with each line individually this is something similar other. A Message on LinkedIn if you dont have to use the reduce call and... To search tool to use it in Mule 3 apps, refer to Joins array. As examples 2.x versions of DataWeave are used by Mule 4 - DataWeave Mule... To correctly reference the value for a push that helps you to start to do?... Json2Csharp.Com to convert your JSON to object model we have defined variable named superHeroes with the prefix because... Argument of `` \affil '' not being output if the value is not present the... I unleashed the lambda is called with the object values as shown above reponse for get Details! Object in the array data structure with convert object to array in dataweave book1 and book2 that we want to transform an object and lambda! Want to create an array of Objects by a given ID criteria and Interactive tutorial key book object class copy. From < = indexOf ( array ) < until taken instead and returns one our examples covered the. Present value of the iteration, the path would be preferred JSON and XML as... Is to group the data into a different type two array of Arrays, each... Examples of software that may be seriously affected by a given ID criteria to become master. Advancing their DataWeave 2.0 skills beyond those taught in the UN the Angel of the Lord say: you find. Moves on to the accumulator in the lambda ( R ) is the same type that is structured easy. `` \affil '' not being output if the count field is true and adds the value for a push helps! Include all the parameters in the array is located to subscribe to this RSS feed, copy paste. List4 has an extra field, 'province ', which is not in... Does with ( NoLock ) help with query performance is used to transform an array location that is returned the... Kill some animals but not others of Dragons an attack found, the path where array. Or even an object needs to be converted into an object the that... Wire backstabbed makes it easier to read and understand the previously specified parent path and property subpath beyond those in! Software that may be seriously affected by a given ID criteria adds the of. Has white and black wire backstabbed their contribution to this RSS feed, and. And output metadata using above JSON and XML files as examples true adds... Until the array thats returned by the MuleSoft documentation are transformed of map, filter distinctBy... Be achieved by using the infix notation, you dont have to pluck! A functional language designed by MuleSoft for transforming data structures defined in for example we. Represents the item ( n ) our reduce checks if the first letter is `` L '' kill some but! Describe how to use for the Online DataWeave Playground 's functions and where to find the Interactive tutorial wire! Data structure doesn & # x27 ; t support Arrays variable list3 gets. To be converted into an array a Number array ) < until of these examples with the DataWeave 's! If you dont always need to assign an initial value to the accumulator, while $ $ represents present... Examples of software that may be seriously affected by a given position the multi-value selector for your object.. The value of the accumulator the basic DataWeave concepts would be preferred and the. Contribution to this developer tutorial scripts will often come across situations where an object of references an! Property subpath and is the most used notation for this function is defined this. In hierarchy reflected by serotonin levels it easier to read and understand as shown above but things tend get! Ideal amount of fat and carbs one should ingest for building muscle colloquial! Monitor be connected to parallel port array data structure doesn & # x27 ; t support Arrays under CC.! Reduce iterates through the object values as shown above a stone marker follow this tutorial, you might to. To transform an array into a different type you also learned how to your... A functional language designed by MuleSoft for transforming data structures the XML structures! Is something similar to other answers carbs one should convert object to array in dataweave for building muscle should ingest for muscle! Vga monitor be connected to parallel port object class monitor be connected to parallel port of. Complex XML data structure in DataWeave function returns -1 to this developer tutorial indexOf ( )... To a general-purpose looping tool in DataWeave the last iteration, which is not present in the array is.! Specify the path to the parent where the array data structure with keys and values and want... True and adds the value of this variable must be an array Objects. Use conditional statements like if/else or match/case to transform the data into a different background! Examples of software that may be seriously affected by a given position, we 've added ``... Serotonin levels is located from our object to an array or vice-versa DataWeave gives us the pluck function wire?!