コード例 #1
0
        public static ScopusResponse ToScopusResponse(string json)
        {
            ScopusResponse        response            = JsonConvert.DeserializeObject <ScopusResponse>(json);
            List <List <string> > responseAuthorsList = new List <List <string> >();

            if (response?.entry != null)
            {
                for (int i = 0; i < response.entry.Count; ++i)
                {
                    ScopusArticle article         = response.entry[i];
                    List <string> responseAuthors = new List <string>();
                    JArray        authorsList     = article?.authorsList?.author as JArray;
                    if (authorsList != null)
                    {
                        List <ScopusArticleAuthorElement> authors = JsonConvert.DeserializeObject <List <ScopusArticleAuthorElement> >(authorsList.ToString());
                        response.entry[i].authors = authors.Select(x => x.author).ToList();
                    }
                    else if (article.authorsList != null && article.authorsList.author != null)
                    {
                        response.entry[i].authors = new List <string>
                        {
                            article.authorsList.author.ToString()
                        };
                    }
                    else
                    {
                        response.entry[i].authors = new List <string>();
                    }
                }
            }
            return(response);
        }
コード例 #2
0
 public static BaseResponse ToBaseResponse(ScopusResponse obj)
 {
     return(new BaseResponse
     {
         status = "OK",
         total = obj?.totalResults != null?int.Parse(obj.totalResults) : 0,
                     data = obj?.entry?.Select(x => ArticleHelper.ToArticle(x)).ToList()
     });
 }