Convert String(binary) to the tuple or Get data

I have params whose type is String(is_binary = true) and following is my params

"{job_id: 5, candidate_ids: 11,6}"

How can I get the data(job_id, candidate_ids) from this string? Also, is it possible to convert it into tuple?

What’s the format the data is encoded in? This doesn’t seem to be json. You’d probably want to stick to an existing encoding standard.

I am passing it using Jquery, as following

      $('.bulk-stage-change-hidden-button')
      .attr(
        'phx-value',
        `{job_id: ${job_stage_id}, candidate_ids: ${pipeline_ids}}`,
      );

in Html

<button class="d-none bulk-stage-change-hidden-button" phx-click="bulk_stage_change" phx-value=""></button>

Then I’d strongly suggest using JSON.stringify({job_id: job_stage_id, candidate_ids: pipeline_ids}) instead of your homebrew data string and on the server side use the json library you probably already have, because phoenix needs one.

4 Likes