我正在基于n1sql语句运行curl命令, 我只需要Json文档(禁止显示标题,统计信息)
这是curl的输出:
namespace Songs
{
class Program
{
static void Main(string[] args)
{
//InputSongDetails();
//Console.WriteLine(InputSongDetails());
Song[] songs = new Song[4];
for (int i = 0; i < songs.Length; i++)
{
songs[i] = InputSongDetails();
}
Console.WriteLine("Enter an artist name, or just press return for all artists");
var name = Console.ReadLine().ToUpper();
name = name.Trim();
foreach (var song in songs)
{
if (string.IsNullOrWhiteSpace(name) || song.GetArtist().Equals(name))
{
Console.WriteLine(song.GetDetails());
if (song.GetCertification() != null)
{
Console.WriteLine(song.GetCertification());
}
var totalCopiesSold = song ;
Console.WriteLine(song.copiesSold);
}
}
}
static Song InputSongDetails()
{
Console.WriteLine("What is the name of your song");
string name = Console.ReadLine();
Console.WriteLine("What is the artists name");
string artist = Console.ReadLine();
int records;
Console.WriteLine("How many records did it sell");
while (!int.TryParse(Console.ReadLine(), out records) || records < 0)
{
Console.WriteLine("That is not valid please enter a number");
}
return new Song(name, artist, records);
}
}
}
namespace Songs
{
class Song
{
string name;
string artist;
public int copiesSold;
public Song(string name, string artist, int copiesSold)
{
this.name = name;
this.artist = artist;
this.copiesSold = copiesSold;
}
public Song() : this("my_name", "my_artist", 1000)
{
}
public string GetArtist()
{
return artist;
}
public string GetDetails()
{
return $"Name: {name} Artist: {artist} Copies Sold: {copiesSold},";
}
public string GetCertification()
{
return copiesSold < 200000 ? null : copiesSold < 400000 ? "Silver" : copiesSold < 600000 ? "Gold" : "Platinum";
}
public void AddCopiesSold(int number)
{
copiesSold += number;
}
}
}
我尝试了不同的参数,但没有任何效果,
没有其他选择,我将curl传递到{
"requestID": "c62382b5-4305-4f8a-a841-003787fe8b5b",
"signature": {"*":"*"},
"results": [
{....JSON DOC DATA...}
],
"status": "success",
"metrics": {"elapsedTime": "4.043682ms","executionTime": "4.00168ms","resultCount": 1,"resultSize": 456}
}
并写入文件,因为Json DATA在第5行中。效果很好,但我无法获取http_code。
awk -v line=5 'NR==line'
我希望得到一个干净的json文档-我更喜欢不处理接收数据并使用curl本机命令。 但是,如果没有选择,是否可以更改命令,以便我仍然可以获取http_code? p>