Quantcast
Channel: Adobe Community : All Content - ColdFusion
Viewing all articles
Browse latest Browse all 5979

How to fix a problem with the order of strings in a JSON response for a CFHTTP request?

$
0
0

Good morning, guys! (It's 10:50 a.m. in Brazil)

 

First of all, I'm still new at CF and my questions may seem too much silly and my English's not the best, so, please be patient with me. hehe

 

Well, I'm accessing a link via CFHTTP that gives me a JSON response. I'm not familiar with JSON yet, so I'm working it as a string and using string functions (Find,RemoveChars,Replace,etc), but it happens to me that I'm receiving a certain kind of order of the strings list from the JSON when I access it directly from the browser and other kind of order totally different when I access it from the CFHTTP.

 

I only figured it out because I was working at home with my code and there everything went just fine as expected. Then I brought to my job to develop a little bit more as soon as I get a free time and here my code doesn't work anymore. When I took a look at the JSON by a CFOUTPUT, I realized the strings were in a different order.

 

Does anyone know why is it happening?

 

Link to the JSON: http://sigmine.dnpm.gov.br/ArcGIS/rest/services/extra/dados_dnpm/MapSe rver/0/query?text=830620/2012&geometry=&geometryType=esriGeometryEnvel ope&inSR=&spatialRel=esriSpatialRelIntersects&where=&returnGeometry=tr ue&outSR=&outFields=FID,Shape,PROCESSO,ID,NUMERO,ANO,AREA_HA,FASE,ULT_ EVENTO,NOME,SUBS,USO,UF&f=pjson

 

Basic code simplified to find out that the order of strings were coming different when access by CFHTTP:

 

<cfhttp url="#URLAbove#"method="get"result="DadosDoDNPM"charset="utf-8"timeout="10000"/>

<cfset DadosJSON = deserializeJSON(DadosDoDNPM.FileContent)/>

<cfifarrayLen(DadosJSON.features)>

    <cfset CodigoFonteJSON = ToString(serialize(DadosJSON.features))/>   

    <cfoutput> #CodigoFonteJSON# </cfoutput>

</cfif>

 

Is there a way to fix it and to make my code work everywhere?

If it matters, I use Railo at home and at my job.

 

Since now, I thank you.


Viewing all articles
Browse latest Browse all 5979

Trending Articles