转换JSON对象时发出的问题

时间:2018-03-15 12:58:14

标签: angularjs json

需要将以下字符串转换为对象

"{"taskStatus":"Not Started","taskFields":{"originalTransactionDate":"${datafield:feerefund:originalTranDate}","transactionPostingDate":"${datafield:feerefund:tranPostingDate}","referenceNumber":"${datafield:feerefund:referenceNum}","promotionIdentifier":"${datafield:feerefund:promoId}","merchantAdjustmentDescription":"${datafield:feerefund:merchantAdjDesc}","transactionAmount":"${datafield:feerefund:tranAmount}","batchPrefix":"${datafield:feerefund:batchPrefix}","transactionCode":"${datafield:feerefund:tranCode}"}}"

3 个答案:

答案 0 :(得分:0)

看看JSON.parse:

let object = JSON.parse(string)

其中string是你的json字符串

答案 1 :(得分:0)

正确的JSON字符串是

empty

并将字符串转换为对象

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using TodoApi;

namespace TestCors
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton<ITaskWarehouse, TaskWarehouse>();

            services.AddCors();
            services.AddMvc();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCors(builder => builder
                    .AllowAnyOrigin()
                    .AllowAnyMethod()
                    .AllowAnyHeader()
                    .AllowCredentials());
            app.UseMvc();
        }
    }
}

答案 2 :(得分:0)

&#13;
&#13;
<h1>Your string input have double quote the end "transactionCode":<del>"</del>"Failed6"</h1>
&#13;
{{1}}
&#13;
&#13;
&#13;