无法使用Json4s反序列化参数“ jsonClass”

时间:2018-11-06 08:47:29

标签: scala json4s

我有一个看起来像这样的json

let ini2Obj = {};
const keyValuePair = kvStr => {
    const kvPair = kvStr.split('=').map( val => val.trim() );
    return { key: kvPair[0], value: kvPair[1] };
};
const result = document.querySelector("#results");
document.querySelector( '#inifile' ).textContent
    .split( /\n/ )                                       // split lines
    .map( line => line.replace( /^\s+|\r/g, "" ) )     // cleanup whitespace
    .forEach( line =>  {                               // convert to object
        line = line.trim();
        if ( line.startsWith('#') || line.startsWith(';') ) { return false; }
        if ( line.length ) {
          if ( /^\[/.test(line) ) {
            this.currentKey = line.replace(/\[|\]/g,'');
            ini2Obj[this.currentKey] = {};
          } else if ( this.currentKey.length ) {
            const kvPair = keyValuePair(line);
            ini2Obj[this.currentKey][kvPair.key] = kvPair.value;
          }
        } 
      }, {currentKey: ''} );

result.textContent += 
    `**Check: ini2Obj['Slave_Settings:11'].ConfigurationfilePath = ${
      ini2Obj['Slave_Settings:11'].ConfigurationfilePath}`;

result.textContent += 
  `\n\n**The converted object (JSON-stringified)\n${
  JSON.stringify(ini2Obj, null, ' ')}`;

我旨在使它去毛刺并构造Scala对象。这是它的模型

var cutJson =
  """
    |{
    | "routingKey": "event.orders.status.paid",
    | "jsonClass" : "Event"
    |}
  """.stripMargin[enter image description here][1]

这是应该去粗麻的行

case class Order(routingKey: String, jsonClass: String)

程序崩溃并显示以下错误,但是,如果我仅使用routingKey参数,则效果很好

这里是error message

0 个答案:

没有答案