question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Placing concatenated string into output array

See original GitHub issue

Input

{
	"id": "01001",
	"name1": "Larry",
	"name2": "Bird",
	"content1": "Basketball",
	"content2": "Court",
	"content3": "Stadium"
}

Spec

[
  {
    "operation": "shift",
    "spec": {
      "content1": [
		    "sports[1].name",
        "player.details[0].sport"
      ],
      "content2": "sports[0].location",
      "id": "player.id",
      "name1": "player.firstname",
      "name2": "player.lastname"
    }
  },
  {
    "operation": "modify-default-beta",
    "spec": {
      "player": {
        "details": {
          "0": {
            "fullname": "=concat(@(1,name1),' ',@(1,name2))"
          }
        }
      }
    }
  },
  {
    "operation": "default",
    "spec": {
      "player": {
        "details[]": {
          "0": {
            "teamname": "Celtics"
          }
        }
      }
    }
  }
]

Output

{
  "sports" : [ {
    "location" : "Court"
  }, {
    "name" : "Basketball"
  } ],
  "player" : {
    "details" : [ {
      "sport" : "Basketball",
      "teamname" : "Celtics"
    } ],
    "id" : "01001",
    "firstname" : "Larry",
    "lastname" : "Bird"
  }
}

I am attempting to get the full name placed in the details array in the player object. I have a feeling it has to do with navigating the tree, but I have been unable to get the values. If you see where this went wrong, your assistance would be greatly appreciated!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
milosimpsoncommented, Nov 6, 2018

Yeah, each operation takes as input the output from the operation before it. Its a transform pipeline.

0reactions
blkdragn77commented, Nov 6, 2018

Thank you for the information! So, in a chain spec, the first operation can see the source JSON. I am assuming the operations are executed in order. So, the source JSON is available for the 1st operation, the result of that is available to the 2nd, and so on…right? Just trying to better understand the mechanics of how operations are processed and what data is available where.

Read more comments on GitHub >

github_iconTop Results From Across the Web

concatenate array elements to form a string - JavaScript
The string that results from converting each element of array to a string and then concatenating them together, with the separator string between...
Read more >
String Concatenation in C++: 4 Ways To Concatenate Strings
The strcat() function takes char array as input and then concatenates the input values passed to the function. Syntax: strcat(char *array1, char ...
Read more >
How to concatenate 2 or more strings as one inside a string ...
Probably the most concise way is: Construct an array of the right size: String[] result = new String[A.length - (y-1)];.
Read more >
Solved: Array (Select) output to a concat string
I'm trying to get a list of email addresses from a Get Items action and use them to create a variable which will...
Read more >
How to concatenate strings in C: A five minute guide
Concatenation involves appending one string to the end of another string. For example, say we have two strings: “C programming” and “language”. ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found