This looks like a job for $.map!

var data = {
    "category": [{
          "id": 28,
          "name": "Dogs"
      },
      {
          "id": 14,
          "name": "Cats"
      },
      {
          "id": 878,
          "name": "Sheep"
      }]
}

var cats = $.map(data.category, function(v){
    return v.name;
}).join(', ');
Answer from gen_Eric on Stack Overflow
🌐
Make Community
community.make.com › questions
How to combine multipe JSON Strings? - Questions - Make Community
August 5, 2024 - Hello Community, I’m feeling quite frustrated right now. For about two hours, I’ve been trying to merge two or more JSON strings into one. Here’s what I’ve done so far: I receive a response from OpenAI and convert that response into structured data. Then, I aggregate a dataset using JSON Aggregate to create a JSON string.
🌐
AskPython
askpython.com › home › what is json and how to merge two json strings?
What Is JSON and How To Merge Two Json Strings? - AskPython
March 16, 2023 - Taking the same strings, we have tried to merge them into a dictionary by parsing them as dictionaries first using the jsonloads() and then merging them using the **. After converting the strings into a dictionary, we merged them into a data frame.
🌐
Tabnine
tabnine.com › home page › code › java › org.json.jsonarray
org.json.JSONArray.join java code examples | Tabnine
public String join(String separator) throws JSONException { return jsonArray.join(separator);
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › org.json.jsonarray.join
JSONArray.Join(String) Method (Org.Json) | Microsoft Learn
Returns a new string by alternating this array's values with separator. [Android.Runtime.Register("join", "(Ljava/lang/String;)Ljava/lang/String;", "GetJoin_Ljava_lang_String_Handler")] public virtual string? Join(string?
🌐
Medium
medium.com › @osamakhann118 › string-concatenation-from-json-array-how-to-concatenate-string-from-json-array-b2074ae34927
String Concatenation from JSON Array | How to concatenate string from JSON array - Osama khan - Medium
December 16, 2022 - String Concatenation from JSON Array | How to concatenate string from JSON array If you want to convert a JSON objects array to a concatenated string follow the following process lets say we have a …
🌐
techtutorialsx
techtutorialsx.wordpress.com › 2020 › 09 › 06 › javascript-merge-json-objects
JavaScript merge JSON objects – techtutorialsx
January 25, 2025 - Both JSON objects will be very simple, representing possible information about a person. One of them contains two properties: name and age. The other also contains two properties: an array of languages the person speaks and a Boolean indicating if the person is married or not. const string1 = `{ "name": "Todd", "age": 20 }`; const string2 = `{ "languages": ["Spanish", "Portuguese"], "married": true }`;
Find elsewhere
🌐
Newtonsoft
newtonsoft.com › json › help › html › MergeJson.htm
Merging JSON
JObject o1 = JObject.Parse(@"{ ... 'Roles': [ 'User', 'Admin' ] }"); o1.Merge(o2, new JsonMergeSettings { // union array values together to avoid duplicates MergeArrayHandling = MergeArrayHandling.Union }); string json = o1.ToString(); // { // "FirstName": "John", // ...
🌐
Medium
allaboutcode.medium.com › javascript-how-to-merge-2-json-strings-together-and-return-a-string-359455bc48f1
Javascript — How to merge 2 JSON strings together and return a string | by Marika Lam | Medium
June 14, 2022 - const string1 = `{"name": "Todd","age": 20}`;const string2 = `{"languages": ["Spanish", "Portuguese"],"married": true}`; 2. After defining these JSON strings, we will parse them to JavaScript objects.
🌐
Microsoft Power Platform Community
powerusers.microsoft.com › t5 › Building-Flows › Concatenate-each-iteration-of-a-JSON-into-a-single-string › td-p › 2072987
https://powerusers.microsoft.com/t5/Building-Flows...
Quickly search for answers, join discussions, post questions, and work smarter in your business applications by joining the Microsoft Dynamics 365 Community.
🌐
CodeProject
codeproject.com › Questions › 1167449 › How-to-incontinent-JSON-strings
How to concatenate 2 JSON strings..?
September 22, 2020 - Do not try and find the page. That’s impossible. Instead only try to realise the truth - For those who code; Updated: 1 Jul 2007
Top answer
1 of 3
10

Alasql JavaScript SQL library does exactly what you need in one line:

 <script src="alasql.min.js"></script>
 <script>
    var data = { COLORS: [[1,"red"],[2,"yellow"],[3,"orange"]],            
                 FRUITS: [[1,"apple"],[2,"banana"],[3,"orange"]]};

    data.NEW_FRUITS = alasql('SELECT MATRIX COLORS.[0], COLORS.[1], FRUITS.[1] AS [2] \
         FROM ? AS COLORS JOIN ? AS FRUITS ON COLORS.[0] = FRUITS.[0]',
         [data.COLORS, data.FRUITS]);
 </script>

You can play with this example in jsFiddle.

This is a SQL expression, where:

  • SELECT - select operator
  • MATRIX - modifier, whci converts resultset from array of objects to array of arrays
  • COLORS.[0] - first column of COLORS array, etc.
  • FRUITS.1 AS 2 - the second column of array FRUITS will be stored as third column in resulting recordset
  • FROM ? AS COLORS - data array from parameters named COLORS in SQL statement
  • JOIN ? ON ... - join
  • [data.COLORS, data.FRUITS] - parameters with data arrays
2 of 3
8

The fact that there will be thousands of inputs and the keys are not necessarily ordered means your best bet (at least for large objects) is to sort by key first. For objects of size less than about 5 or so, a brute-force n^2 approach should suffice.

Then you can write out the result by walking through the two arrays in parallel, appending new "records" to your output as you go. This sort-then-merge idea is a relatively powerful one and is used frequently. If you do not want to sort first, you can add elements to a priority queue, merging as you go. The sort-then-merge approach is conceptually simpler to code perhaps; if performance matters you should do some profiling.

For colors-without-fruits and fruits-without-colors, I assume writing null for the missing value is sufficient. If the same key appears more than once in either color or fruit, you can either choose one arbitrarily, or throw an exception.

ADDENDUM I did a fiddle as well: http://jsfiddle.net/LuLMz/. It makes no assumptions on the order of the keys nor any assumptions on the relative lengths of the arrays. The only assumptions are the names of the fields and the fact that each subarray has two elements.

🌐
KNIME Community
forum.knime.com › knime analytics platform
How to concatenate json or string outputs from two nodes - KNIME Analytics Platform - KNIME Community Forum
December 24, 2019 - Hi, I want to produce a single JSON file with two key-value pairs. I have two database views which I have used in ‘DB Query Reader’ nodes and then I am converting two outputs to two different Json using ‘Table to Json’…
🌐
JSONata
docs.jsonata.org › string-functions
String functions · JSONata
If separator is not specified, then it is assumed to be the empty string, i.e. no separator between the component strings. It is an error if separator is not a string. ... $split("too much, punctuation. hard; to read", /[ ,.;]+/, 3) ~> $join(', ') => "too, much, punctuation"