在颠簸转换中将字符串转换为数组

我有一个这样的输入json:

输入:

#include<stdio.h>
#include<ctype.h>
#define MAX_SIZE 100

int main(){
    int i;
    char c[MAX_SIZE]={0};
    printf("Enter message:");

    for(i=0;getchar()!='\n';i++){
        c[i] = getchar();    /*looks like some error here that the compiler didn't found out.....*/
    }

    for(i=0;c[i]!='\n';i++){
        putchar(c[i]);
    }

    return 0;
}

在这里,我需要更改密钥-authtype并将这些值放入数组中。

期望的杰森:

{
     "userstatus": {
         "authtype": "S,R,T",}
}

但是我的实际输出是这样的:

{
    "userstatus": {
        "authtype": ["S","R","T"]
    }
}

JOLT SPEC:

{
    "authtype" : [ "S,T" ]
}

请为上述测试用例提供帮助吗?

bendan0663 回答:在颠簸转换中将字符串转换为数组

这是您的规格。您应该在修改操作中使用分割功能。

int lifePoints = 100;
// not a full code but just giving an explanation
if (player == ("attackthem!"))
  {

    change integer value here. how?

  }
本文链接:https://www.f2er.com/3153563.html

大家都在问