Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid json format err when the shell script contain \ #6

Open
shumin1027 opened this issue May 15, 2020 · 2 comments
Open

invalid json format err when the shell script contain \ #6

shumin1027 opened this issue May 15, 2020 · 2 comments

Comments

@shumin1027
Copy link

shumin1027 commented May 15, 2020

when the shell script contain \, unmarshal json string will go wrong
job shell:

#!/bin/bash

#BSUB -n 1
#BSUB -R "span[ptile=24]"
#BSUB -e %J.err
#BSUB -o %J.out
#BSUB -J testjob

echo -e "\nhello, \
\"lsf\""

sleep 5

if the shell script contain some characters that may affect json structure,may trigger unmarshal json string error

image

the fields such as command, job_name most likely to be affected

@shumin1027
Copy link
Author

shumin1027 commented May 15, 2020

need a better way to solve this kind of problem completely #2

I think there are two possible ways

  1. a better json library ,render the string provided to an escaped version that can be printed
    reference:
    cJSON
    rapidjson

  2. base64 encode the fields that may be affected

@adamsla
Copy link
Contributor

adamsla commented May 15, 2020

Yea, for things like Cacti and RTM, I use base64 encoding. But I do mostly things in PHP and don't generally have issues with JSON in POST. Thanks for the pointers. Let's keep this discussion going with Dev. I gave them a bump. They do product first, and this stuff when they have free cycles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants