Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
How do I convert below input string (which will be retrieved from config.yaml properties file) to required json object using Dataweave?
Input:
"ABC:123,DEF:456,GHI:789"
Required Output:
{ "ABC":"123", "DEF":"456", "GHI":"789" }
splitBy and reduce can be used like below
("ABC:123,DEF:456,GHI:789" splitBy ",") reduce ((item, accumulator={}) -> accumulator ++ do { var items = item splitBy ":" --- (items[0]): items[1] })
Add a comment
%dw 2.0 output application/json --- {(("ABC:123,DEF:456,GHI:789" splitBy ",") map { ({ (($ splitBy ":")[0]): (($ splitBy ":")[1])}) })}
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.