Category Archives: How to Fix

JSON data format net.sf.json .JSONException: A JSONObject text must begin with ‘{‘ at character 1 of Error:(f…

The substring (3) the use of the http://www.w3school.com.cn/jsref/jsref_substring.asp

Possibility 1: if sb is the data to be converted, let’s say sb is a String

 


The char
The STR [] = sb. ToString (). ToCharArray ();


for
(
The int
i=
0
; i< str.length; i++){


System.out.println(str[i]);


}

After can get into an array of form, check the array before any Spaces, such as if useful
sb.toString().trim().substring(
1
); Cut off


The String json = sb. ToString (). The trim (). The substring (
1
);


The // String json = "{\" success \ ": true, \" MSG \ ": \ \" successful "} ";


System.out.println(json);


System.out.println(json.length());


The JSONObject JSONObject = JSONObject. FromObject (json. The trim ());


System.out.println(jsonobject);



The

"Result" : [{}] ------ left less {

Possibility 2: No initialization, no initBmob () is likely to report this wrong Unregistered

Possibility 3: There is an extra space before the data in the database

 

Reproduced in: https://www.cnblogs.com/wth21-1314/p/7381575.html

209151; org.json.JSONException A JSONObject text must begin with'{‘at character 1 of {

Cause analysis:
parse the json data, the format is not correct, is usually as a result of the returned json data outside a layer of more “” (double quotes)
if, as a string, plus @ ResponseBody annotation, then parsing json over there will more outside a layer of” ”
Solutions:

(1) if the string is converted to json, then you need to call the json packet method (string turn json object), and then forwards the json object resolution in the past.
2. If the entity object, you need to call the Json packet method (object turn Json object), and then forwards the Json object resolution in the past.
no matter what you need to turn the object data type, anyhow can not directly return to the past for Json parsing, need to convert a Json object before parsing.
Last word: it’s not easy to write. If you like it or find it helpful, remember to follow it or bookmark it

ansoft:Com Engine non-responsive since

Ansoft :Com Engine Non-responsive since 17:23:04, October 18, 2015.If Persisting for Long, Functional Testing kills the Com Engine Process and Restart Analysis.
When this situation occurs in Ansoft simulation, the progress bar is 0 and unchanged. Many methods have been tried on the Internet, but the software crashed and was closed and then opened, which can be simulated normally.

Activity of Android studio_ main.xml Unable to preview (gray page)

The activity_main.xml in Android Studio cannot be previewed (the gray page only displays the ActionBaroverLayout) and controls cannot be pulled into it. The styles.xml file is in the values file

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>

To change to the preview state, add “base.” before the Theme in the

[Jackson exception] com.fasterxml.jackson . databind.JsonMappingException Exception handling method

In the project, the parent layer is Car.java [Vehicle Entity] and the child layer is CarCommonParam.java [Vehicle Basic Entity], which is the basic information of a vehicle to multiple vehicles
But at the time of query library collection is a entity error: 【 com. Fasterxml. Jackson. Databind. JsonMappingException 】

com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: cn.skyable.zulin.common.bean.CarCommonParam_$$_jvst95e_39["handler"])
X-Zc-Ack-->null
	at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:59)
	at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:26)
	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:541)
	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:644)
	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:152)
	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:114)
	at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:1837)
	at com.fasterxml.jackson.core.base.GeneratorBase.writeObject(GeneratorBase.java:261)
	at com.ablecloud.cloudservice.ACObjectMarshaller.marshalArray(ACObjectMarshaller.java:53)
	at com.ablecloud.cloudservice.ACObjectMarshaller.marshalObject(ACObjectMarshaller.java:37)
	at com.ablecloud.cloudservice.ACObjectMarshaller.marshal(ACObjectMarshaller.java:22)
	at com.ablecloud.common.ACObject.toString(ACObject.java:415)
	at java.lang.String.valueOf(String.java:2994)
	at java.lang.StringBuilder.append(StringBuilder.java:131)
	at cn.skyable.zulin.BaseTest.dealResp(BaseTest.java:88)
	at cn.skyable.zulin.logistics.TestLogistics.TestlistCarsByLogId(TestLogistics.java:65)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:539)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:761)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:461)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:207)

Error description: A truncation is made in the entity where the child layer can look up information about the parent layer, but the parent layer cannot look up information about the child layer due to circular reference problem.
Solution:
Add to the parent car.java
Instead of

Just !!!!

JSON parse error: invalid UTF-8 solution series

Today, the code passed the local test and the Tomcat server was deployed. My front-end colleague gave me the following error feedback:

Request","exception":"org.springframework.http.converter.HttpMessageNotReadableException","message":"JSON parse error: Invalid UTF-8 middle byte 0x3f

I immediately started the local project and asked colleagues in the front end to connect my local project for relevant function prompts. The result was that everything was normal without any problem, and the response error messages returned by checking the front end were all 400.
The error screenshot is not saved. The format of the error response is as follows:
To be added.
 
We must be clear here: in response to the 400 error code, there are several reasons for the error:
Tomcat service transport encoding format not specified (UTF-8)
Tomcat server JAR file encoding format not specified (UTF-8)
The front-end request header parameter does not match the backend parse header parameter.
Step 1: Configure the Tomcat server to transfer the encoding format specified:
Edit the tomcat/conf/server.xml file and add encoding attributes to the Connector tag: uriEncoding =”UTF-8″

Setjava_opts =%JAVA_OPTS% -dfile.encoding =UTF-8; setjava_opts % -dfile.encoding =UTF-8

SpringMVC backend code specifies request header information:

Exception jsonmappingexception: out of start_ ARRAY token

1 problem
When a new HTTP interface is called and the data is parsed, an exception is raised:
Under Caused by: com. Fasterxml. Jackson. Databind. JsonMappingException: Can not deserialize the instance of the com. Out of XXX START_ARRAY token
The second analysis
If you look at the JSON data for the data, it’s an array. The original one is encapsulated as response.
So, you can encapsulate. Modify parsing without encapsulation:

objectMapper.readValue(json,XXOjject[].class);

This is an array object that can be converted to a list and returned normally.

Clion automatically adds add_ executable

CLion automatically adds add_executable
Install the C/C++ Single File Execution plugin, search for the C/C++ Single File Execution, find file-settings-plugins, and apply.
The preparations are complete. Next you can create a new C/ CPP file, enter the code, press Ctrl + Alt + Shift +E shortcut or right click in the code area and find Add Executable for Simple C/C++ File, then right click on the item area on the left and select Reload Cmake Project, select Auto-Reload so that it will automatically add to the executable after each right click on Add.

A method of generating subtitle file for MP3

In the current cloud computing, big data and artificial intelligence are so hot, all kinds of cloud services providing voice recognition are emerging. Recently, I tried to make a tool based on IBM Watson Speech to Text Service to help generate English MP3 subtitle files, I think it is good, and I share it as follows.
The tool is compiled in C#, and the specific idea is as follows:

Step 1: Use the embedded WebBrowser to access the relevant IBM service website: https://speech-to-text-demo.ng.bluemix.net/. The interface will look like this:

In this step, you need to manually click the “Upload Audio File” button of the webpage and select the MP3 Audio File to be subtitled. After the upload is successful, the site will start the automatic recognition process. Once you have identified the words, manually click on Word Timings and Alternatives at the bottom to see the sequence of the words you identified and the corresponding start time.

Note :(1) The save button at the top of the interface can save the identified webpage content to local HTM file, and you can click the load button to load it directly next time, without repeating the identification process.
(2) When clicking the “Next” button at the bottom of the interface, the program will automatically scan the web content to generate a dictionary list of words and time information, denoted here as lstDict, of type List< KeyValuePaire< string, string> > , each element in the list is a key-value pair, the Key stores the word, the Value stores the time information.

Step 2: Load the English manuscript. If the original is not available, copy the identified text from the Step 1 site under the Text TAB. The interface is shown below:

In this step, the original text as far as possible to meet the following requirements:

(1) Completely corresponding to audio text.

(2) Each line contains words as long as possible, which can improve the matching rate.

(3) Avoid non-English characters, especially Chinese or non-half-corner symbols.

Step 3. Generate the subtitles. The program will sequentially input the original line by line and the first step to identify the word time dictionary to match, in order to get the beginning time of each line of subtitles. The general idea is as follows:

(1) Word segmentation: Use regular expressions to split the current line into an array of words. The code is as follows:

string[] a = Regex.Split(value, @"\s+");

(2) Denoising: remove or replace symbols that do not conform to English habits in each word in the array to symbols that conform to English specifications.

(3) Match: Match the array with the word time dictionary identified in the first step, lstDict, to get the start time of the subtitle for that line.

The following figure shows the interface of recognition result:

At this time, notice that the time marked in red in the figure is obviously incorrect, you can manually select the corresponding time through the “Correct” function at the top of the interface. The interface is shown below:

At this point, the subtitle information is matched, you can click the Save button at the bottom of the file to save the corresponding format of the subtitle file, currently provides support for.lrc and.smi formats.

Note: Click the play button at the top of the interface to select the audio file to play in real time and view the generated subtitle effect.

Finally, the download address is attached:
https://download.csdn.net/download/alvin_2005/10530316

How to convert audio to subtitle (text) with Python?

For example, you can use “Speech_Recognition” for your certificate using Python. For example, you can use “Speech_Recognition” for your certificate using Python. For example, you can use “Speech_Recognition” for your certificate using Python instead of using “username+ PWD”

Using the curl command, you can use the URL to convert audio to text.

curl -X POST -u "apikey:{apikey}" --header "Content-Type: audio/flac" --data-binary @{path_to_file}audio-file.flac "{url}/v1/recognize"

To do this, you need to use the curl command to do something that you want to do. To do this, you need to do something that you want to do. To do this, you need to do something that you want to do.

import requests

headers = {
    'Content-Type': 'audio/flac',
}

data = open('audio-file.flac', 'rb').read()
r = requests.post('https://gateway-wdc.watsonplatform.net/speech-to-text/api/v1/recognize', headers=headers, data=data, auth=('apikey', '***************************'))
print(r.text)

Test effect:

This doesn’t even need to pack well….. It’s OK to request the interface directly. Finally, attach the original version of the code to call the interface implementation method:

import speech_recognition as sr
import requests

harvard = sr.AudioFile('23.wav')
r = sr.Recognizer()
with harvard as source:
    audio = r.record(source)
print(type(audio))

IBM_USERNAME = '************************'
IBM_PASSWORD = '************************'

text = r.recognize_google(audio, username= IBM_USERNAME, password = IBM_PASSWORD, language = 'zh-CN')
print(text)

 
 

[Altium problem] “extra pin u1-22 in normal of part U1”

“Extra Pin U1-22 in Normal of part U1”, as shown in the figure below:

Cause analysis: the principle is that all modes of the components in the component library cannot match the introduced modes in PCB. The solution is either to complete or delete them until only one is left.
Delete solution:
1. Enter the library file. Duplicate a new component and rename it to “+Normal”.
2. Delete redundant modes:

3. Then the compiler will not have this error.