json

XSLT 1.0 escaping double quotes and backslash in a string

吃可爱长大的小学妹 提交于 2021-02-19 03:13:28
问题 I have a string like below and trying to convert into json format: Test "out" and \new Expected output is Test \"out\" and \new I tried by calling templates for escapequote - working fine for escape quotes: <xsl:template name="escapeQuote"> <xsl:param name="pText" select="concat(normalize-space(.), '')" /> <xsl:if test="string-length($pText) >0"> <xsl:value-of select="substring-before(concat($pText, '"'), '"')" /> <xsl:if test="contains($pText, '"')"> <xsl:text>\"</xsl:text> <xsl:call

Is there a way to determine whether a file is in YAML or JSON format?

陌路散爱 提交于 2021-02-19 02:31:10
问题 I have a Python test script that requires a configuration file. The configuration file is expected to be in JSON format. But some of the users of my test script dislike the JSON format because it's unreadable. So I changed my test script so that it expects the configuration file in YAML format, then converts the YAML file to a JSON file. I would prefer that the function that loads the configuration file to handle both JSON and YAML. Is there a method in either the yaml or json module that can

Converting Firebase Datasnapshot to codable JSON data

ぃ、小莉子 提交于 2021-02-19 02:26:21
问题 I am using Firebase Database and am attempting to retrieve and use data using NSObject. I am receiving a NSUnknownKeyException error when running the app causing it to crash. NSObject: class WatchList: NSObject { var filmid: Int? } Firebase Code: ref.child("users").child(uid!).child("watchlist").observe(DataEventType.childAdded, with: { (info) in print(info) if let dict = info.value as? [String: AnyObject] { let list = WatchList() list.setValuesForKeys(dict) print(list) } }, withCancel: nil)

Ajax pass a “Map” object to Spring MVC Controller

我的梦境 提交于 2021-02-19 01:47:30
问题 It seems like Spring MVC doesn't know how to map a javascript "map" to a Java map object In the web UI, say, foo.jsp, <script> var myMap = {}; myMap["people"] = ["Alex","Bob","Charles","Dave"]; myMap["fruit"] = ["Apple","Orange"]; $.ajax({ type : "POST", url : "/myURL", data : "myMap=" + myMap, // I tried "myMap="+JSON.stringify(myMap), as well, it doesn't work neither success : function(response) { alert("Success! response = " + response); }, error : function(e) { alert("AJAX error"); } });

Use jackson annotation JsonUnwrapped on a field with name different from its getter

穿精又带淫゛_ 提交于 2021-02-19 01:26:07
问题 I have a class like: class Car { private Engine myEngine; @JsonProperty("color") private String myColor; @JsonProperty("maxspeed") private int myMaxspeed; @JsonGetter("color") public String getColor() { return myColor; } @JsonGetter("maxspeed") public String getMaxspeed() { return myMaxspeed; } public Engine getEngine() { return myEngine; } } and Engine class like class Engine { @JsonProperty("fueltype") private String myFueltype; @JsonProperty("enginetype") private String myEnginetype;

Chrome Extension: On browser action, create a pop up and execute a script

☆樱花仙子☆ 提交于 2021-02-19 00:52:21
问题 I'm building a Chrome extension and would like to show a pop up and run a script when the user clicks on a browser action icon in Chrome. I can get the popup to occur by putting '"default_popup": "popup.html"' in manifest.json. However, when I do, background.js doesn't seem to run. When I remove '"default_popup": "popup.html"', background.js seems to run. How can I get both the popup to appear and the script to run? manifest.json { "manifest_version": 2, "name": "Typo Blaster", "description":

Chrome Extension: On browser action, create a pop up and execute a script

只愿长相守 提交于 2021-02-19 00:46:18
问题 I'm building a Chrome extension and would like to show a pop up and run a script when the user clicks on a browser action icon in Chrome. I can get the popup to occur by putting '"default_popup": "popup.html"' in manifest.json. However, when I do, background.js doesn't seem to run. When I remove '"default_popup": "popup.html"', background.js seems to run. How can I get both the popup to appear and the script to run? manifest.json { "manifest_version": 2, "name": "Typo Blaster", "description":

JS cannot parse JSON with unicode character

人走茶凉 提交于 2021-02-18 22:34:40
问题 I have the following JSON string {"name":""C\u008cUR Carmen"} but \u008c is not parsed. It shows empty character instead. json = '{"name":"C\u008cUR Carmen"}'; json = JSON && JSON.parse(json) || $.parseJSON(json); Show : CUR Carmen Expect : CŒUR Carmen Please help. * Note * : The JSON data is returned by the PHP server so there shouldn't be any syntax error because I used json_encode and get the response from AJAX. It works with other characters such as à, é but only this wierd character

How do I ignore decoding failures in a JSON array?

我们两清 提交于 2021-02-18 22:15:30
问题 Suppose I want to decode some values from a JSON array into a case class with circe. The following works just fine: scala> import io.circe.generic.auto._, io.circe.jawn.decode import io.circe.generic.auto._ import io.circe.jawn.decode scala> case class Foo(name: String) defined class Foo scala> val goodDoc = """[{ "name": "abc" }, { "name": "xyz" }]""" goodDoc: String = [{ "name": "abc" }, { "name": "xyz" }] scala> decode[List[Foo]](goodDoc) res0: Either[io.circe.Error,List[Foo]] = Right(List

How to know if the iframe content is html or json on load event

廉价感情. 提交于 2021-02-18 22:12:26
问题 I have an event handler function bound to the load event of an iframe, and I want to know if the content retrieved inside the iframe is HTML or JSON. Is there a way to achieve this? 回答1: After some research, the most feasible way I found to know which kind of content is loaded in the iframe is trough the contentType/mimeType properties of the document DOM element. We can get this property in different ways: Inside the load handler function (way 1): var iframedocument = $(this).contents().get