English 中文(简体)
如何将JSON Jtring值转换为提升的普通力量?
原标题:How to convert a JSON JString value to an ordinary String in Lift?

附有<代码>jString : JString Value with an abc>string within I can JString(abc)”: String ,如果我打电话jString.toString。 我如何获得<条码>“abc”:Sting?

问题回答
val jstring=JString("abc")
implicit val formats = net.liftweb.json.DefaultFormats 
System.out.println(jstring.extract[String])

我认为最好的办法是:

val x = ... (whatever, maybe it s a JString)

x match {
  case JString(s) => do something with s
  case _          => oops, something went wrong
}

此前曾有人问过这一点,但我希望有一个简单的一线助手,在表达的背景下,我会为我提供大声帮助,因此,我只字不提一个叫Get的物体:

  object Get {
    def string(value: JValue): String = {                                                                                                               
      val JString(result) = value                                                                                            
      result                                                                                                                              
    }
  ...
  }

这样,我就能够这样做,例如,打上我的标准=Get.string(jsonStringValue)





相关问题
Simple JAVA: Password Verifier problem

I have a simple problem that says: A password for xyz corporation is supposed to be 6 characters long and made up of a combination of letters and digits. Write a program fragment to read in a string ...

Case insensitive comparison of strings in shell script

The == operator is used to compare two strings in shell script. However, I want to compare two strings ignoring case, how can it be done? Is there any standard command for this?

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

String initialization with pair of iterators

I m trying to initialize string with iterators and something like this works: ifstream fin("tmp.txt"); istream_iterator<char> in_i(fin), eos; //here eos is 1 over the end string s(in_i, ...

break a string in parts

I have a string "pc1|pc2|pc3|" I want to get each word on different line like: pc1 pc2 pc3 I need to do this in C#... any suggestions??

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签