Alexander (HH): Perl-Hash nach JSON

Beitrag lesen

Moin Moin!

Ok, vielen Dank euch allen. Schaue ich mir an.

Was ich brauche, ist eigentlich diese XML-Struktur in JSON, weil das dann für eine Android-Programmierung gebraucht wird:

Und Android kann nicht mit XML umgehen? Wunder über Wunder ...

<books>
<book id="1">
   <author>author1</author>
   <title>title1</title>
</book>
<book id="2">
   <author>author2</author>
   <title>title2</title>
</book>
</books>
...


>   
>   
> In der Daetenbank ist es einfach zeilenweise abgelegt:  
> 1 | author1 | title1  
> 2 | author2 | title2  
> ...  
>   
> und ich denke mir, dass dies dann in JSON so aussehen müsse:  
>   
> id: 1  
>  author: "author1"  
>  title: "title1",  
> id:2  
>  author: "author2"  
>  title: "title2",  
> ...  
  
Das ist kein JSON, höchstens vielleicht [YAML](http://de.wikipedia.org/wiki/YAML).  
  
Das ist JSON:  
  
~~~javascript
  
[  
  {  
    "id":1,  
    "author":"author1",  
    "title":"title1"  
  },  
  {  
    "id":2,  
    "author":"author2",  
    "title":"title2"  
  }  
]  

Das auch:

  
{  
  1 : {  
    "author":"author1",  
    "title":"title1"  
  },  
  2 : {  
    "author":"author2",  
    "title":"title2"  
  }  
}  

Such Dir aus, was dem Client besser paßt.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so".