json request issue with newline (\n) in ios - json

I am using afnetworking for json request, and I am passing string like "hello
world". afnetworking json data converts it to "hello\\nworld". but php webservice getting it as "hello\nworld"(my json string). can any one give solution for it. please reply as soon as possible.
Thank you in advance.

Related

How do I convert the following data serialization format into POJO or JSON?

I was expecting a JSON string while testing an API using Postman, but instead got this:
{city=Shanghai, work=112-454-7895, fax=788-899-7899}
Obviously I cannot put that into Google and ask what format is it, hence I am asking it here. Postman also says it is a 'bad string'.
I have never seen the above data serialization format. If someone can point the format out to me I would be able to find and use a converter. Additional suggestion with converting it to POJO or JSON are welcome as well.
I figured out that the above format is a stringified version of a HashMap<String, String>, and that there is no direct way to convert it into JSON/POJO. Converting it into json string requires additional work but is fairly straightforward.

Malformed JSON in Yahoo response

I am trying to get Yahoo user email by decoding ID Token like here in Ruby. I have a token docoding it with Base64.decode64, parsing JSON and here problem come up. String I am trying to parse to JSON is invalid.
Sorry for this copy-paste have problem with formatting it.
START
{"at_hash":"pNgANAsIViDvJ7OCgSk1hw==","sub":"C4SNYQZSHET33BLBTUM3NU2KVP","email_verified":true,"birthdate":"1984","iss":"https://api.login.yahoo.com","profile_images":{"image64":"https://ws.progrss.yahoo.com/progrss/v1/user/C4SNYQZSHET33BLBTUM3NU2KVP/profile/picture
[XYNL΋XZ݌KӖTVU [Y^OM
SLӕLՔ
ٚ[KX\O˚[Y^OLNL
N[XY΋XZ݌KӖTVU
SLӕLՔ
ٚ[KX\Bw6S##"vS3"#&GG3w2&w'726&w'72cW6W"E44UC34$ET$e&f7GW&Pͥȉ艕ULٕ}興Ր艑IYY])DYY9!5)4)9]9!EL4Ռa)]9aE}ѥ͕݅}ذЈ݅兡
END
It looks like the string is cut before its end. Is there any way to get proper JSON?
I am using Ruby 2.4.1

JMeter Groovy convert JSON response to string

I've been looking through various solutions for converting JSON responses to string, but I'm still getting something wrong.
I'm trying to read the response from a post request, convert it to a string and modify it (using groovy), then pass it on the next request. The problem seems to be in the groovy script, it's not reading in the response from the first HTTP request and I'm not sure how to fix that.

Paypal API: NOT json response

I'm trying to execute example from here: https://developer.paypal.com/docs/classic/paypal-payments-pro/gs_PayPalPaymentsPro/
curl -s --insecure https://api-3t.sandbox.paypal.com/nvp -d "USER=platfo_1255077030_biz_api1.gmail.com&PWD=1255077037&SIGNATURE=Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf&METHOD=DoDirectPayment&VERSION=78&PAYMENTACTION=SALE&AMT=5&ACCT=4660997962602322&CREDITCARDTYPE=VISA&CVV2=176&FIRSTNAME=James&LASTNAME=Smith&STREET=FirstStreet&CITY=SanJose&STATE=CA&ZIP=95131&COUNTRYCODE=US&EXPDATE=092015"
Documentation says:
Request method, format Response format
HTTP GET Name/value pairs JSON
But I receives:
TIMESTAMP=2015%2d01%2d30T12%3a14%3a08Z&CORRELATIONID=474de7dae8e82&ACK=Success&VERSION=78&BUILD=15009693&AMT=5%2e00&CURRENCYCODE=USD&AVSCODE=X&CVV2MATCH=M&TRANSACTIONID=93V64243P1844913T
Why? How to get json response?
I tried to set:
VERSION=95
but didn't help.
As document states the paypal NVP api doesn't straight away provide json response.
The way attained to process the response goes like below,
In PHP
parse_str($response,$responseArray);
$jsonResponse = json_encode($responseArray);
helped me to get the array from the response string and in turn converted to json.
Edit : you first need to decode the urlencoded string.
For that
$response = urldecode($response);
Before parsing the response to array.
While I do see the documentation you quoted (from https://developer.paypal.com/docs/classic/paypal-payments-pro/gs_PayPalPaymentsPro/), I think it's flat-out wrong.
I don't believe the classic PayPal APIs support JSON (except Adaptive Payments, which was written later # PayPal & is thus a bit more modern in some ways, including the JSON support).
See https://developer.paypal.com/docs/classic/api/gs_PayPalAPIs/, which describes the headers taht you can use to request JSON from the Adaptive APIs but clarifies that the other classic APIs don't support it.

Does OData4j request a response in JSON format or convert the response to JSON format? (Android)

I've been using the following code to create my android OData service consumer.
Services = ODataConsumer
.newBuilder("http://xxx.xxx.xxx.xxx:xxxxx/WCFDataServices.svc/")
.setFormatType(FormatType.JSON).build();
What I want to know is when the client makes a request through the Services consumer will the request make the server create a JSON formatted response or will the OData4j/consumer convert the response to JSON format.
Thanks in advance for the help. :)
It requests a JSON response from the server using the Accept request header. It does no conversion.
See: http://code.google.com/p/odata4j/source/browse/odata4j-jersey/src/main/java/org/odata4j/jersey/consumer/ODataJerseyClient.java#175
Hope that helps,
- john
Odata defalut format is ATOM. If you want you can change it to JSON, as you already doing.
"FormatType.JSON"
OData4j/consumer APIs are responsible to convert the response type whatever format you have defined.